Ruby was popular by accident. Rails was popular because it was valuable.
Rails was ahead of it's time. The alternatives in that era were ... well, they aren't around any more. Rails was to the alternatives what an iPhone is to a flip phone.
Python is useful with a low barrier to entry. It's valuable and available. It isn't competing with anything. It's useful in the way that spreadsheets are useful.
Just as databases didn't "lose" because spreadsheets are more widely used, neither Ruby nor Python has won or lost. Python is more useful in high-value areas, particularly data science. And ruby is still more fun.