Finding highest ratings with acts_as_rateable

so i can find and set a Posts rating with the acts_as_rateable plugin.
but how would i go about searching for the highest rated Posts, ie.
search by rating.

acts_as_rateable? Are there plug-ins for everything? Is there an
acts_as_profitable yet?

My best idea is to

posts = Post.find(:all)
sorted_posts = post.sort_by { |post| post.rating }.reverse
highest_rated_post = sorted_posts.first

There’s gotta be a better way though.


Well you could iterate through them all one at a time. if
current_highest_post.rating > next_post.rating else move on to the next

thanks josh. works like a charm.

a general question of database retieval efficiency.
if my database starts to get really large, how will find(:all) searches
impact on this. ie. will they start to bottledown my application.
should i always be restricting finds, like so:
posts=Post.find(:all, :order => ‘visit_count DESC’, :limit=>200)

look at the sql queries it uses and then write your own that mimics

On Tue, Oct 10, 2006 at 5:59 PM, mr_robot