Forget what I said here, it’s really inefficient… I just stumbled upon (or actually really searched for) a article, which describes an easy way to cache the rating and make searches as performant as it was before we put the rating into an extra table.
Only thing I had to add was a method to regenerate the cache for all the old quotes, which don’t have the cached rating yet. So, check out the howto and add the following method to your rated model:
self.find(:all).each do |quote|
quote.update_attribute :rating_cache, quote.rating