On Nov 10, 6:48 am, Jeff Pritchard <rails-mailing-l...@andreas-s.net>
wrote:
> It seems like this should be very simple and very common.
>
> I'm using "acts_as_rated" plugin to rate images
> I'm using mislav-will_paginate gem to paginate a list of images
> (not really relevant, but also using paperclip to attach the photo to
> the "image" model
>
> I figured I could do something like this:
> @images = Image.paginate(:page => params[:page], :per_page => 10, :order
> => 'rating_avg')
>
> rating_avg is the name of the average rating in acts as rated
>
I'm not familiar with acts_as_rated, however: where is the rating_avg
column ? if it is on some separate table then you'll need to join on
that table.

Fred
> I get this error:
> Mysql::Error: Unknown column 'rating_avg' in 'order clause': SELECT *
> FROM `images`      ORDER BY rating_avg LIMIT 0, 10
>
> I'm using the:
> :with_stats_table => true
> option
>
> What's the right way to do this rather obvious action of sorting the
> output of a rated model and paginating with will_paginate?
>
> thanks,
> jp
> --
> Posted viahttp://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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to