$300,000 seems like a large overestimate to me, although a site that size would cost a lot of money- we could be talking at least $$,$$$.
I don't know much about Ruby on Rails, so I don't know anything about it's limits. Perhaps your coder failed to emphasize efficiency in the coding, especially if it wasn't completely custom built. I don't know if we have any Ruby on Rails coders in this forum, so I'm not sure how much help you can get in that respect.
If you're talking about millions of users you'd also end up hosting on your own dedicated servers with high efficiency OS's, Oracle Database, etc. All these would make the price climb very fast. But if your site is taking off that much, the money would be there.