hi 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. tx --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
acts_as_rateable? Are there plug-ins for everything? Is there an acts_as_profitable yet?> From: mr_robot <robopop-aCaOOF52aklWk0Htik3J/w@public.gmane.org> > Reply-To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > Date: Tue, 10 Oct 2006 16:55:31 -0700 > To: "Ruby on Rails: Talk" <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > Subject: [Rails] finding highest ratings with acts_as_rateable > > > hi > 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. > tx > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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. -j On 10/11/06, HH <lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org> wrote:> > acts_as_rateable? Are there plug-ins for everything? Is there an > acts_as_profitable yet? > > > > From: mr_robot <robopop-aCaOOF52aklWk0Htik3J/w@public.gmane.org> > > Reply-To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > Date: Tue, 10 Oct 2006 16:55:31 -0700 > > To: "Ruby on Rails: Talk" <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > Subject: [Rails] finding highest ratings with acts_as_rateable > > > > > > hi > > 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. > > tx > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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 one. On 10/10/06, Josh Stephenson <jstepper-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > 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. > > -j > > On 10/11/06, HH <lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org> wrote: > > > > acts_as_rateable? Are there plug-ins for everything? Is there an > > acts_as_profitable yet? > > > > > > > From: mr_robot <robopop-aCaOOF52aklWk0Htik3J/w@public.gmane.org> > > > Reply-To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > Date: Tue, 10 Oct 2006 16:55:31 -0700 > > > To: "Ruby on Rails: Talk" <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > Subject: [Rails] finding highest ratings with acts_as_rateable > > > > > > > > > hi > > > 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. > > > tx > > > > > > > > > > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
look at the sql queries it uses and then write your own that mimics them. On Tue, Oct 10, 2006 at 5:59 PM, mr_robot <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > hi > 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. > tx > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---