Frederick Cheung wrote: > On Nov 11, 3:07�am, Jeff Pritchard <rails-mailing-l...@andreas-s.net> > wrote: >> > Well unless you care particularly about what the join looks like you > can just add :joins => rating_statistic to your find. Do take the time > to familiarize yourself with this sort of stuff though or it will bite > you on the ass eventually. > > Fred
Thanks Fred. No joy. This works fine but doesn't order anything (obviously): @images = Image.paginate(:page => params[:page], :per_page => 10) This @images = Image.paginate(:page => params[:page], :per_page => 10, :order => 'rating_avg') gives me this error: Mysql::Error: Unknown column 'rating_avg' in 'order clause': SELECT * FROM `images` ORDER BY rating_avg LIMIT 0, 10 And your suggestion (slightly modified by me [single quotes added to rating_statistics] gives this @images = Image.paginate(:page => params[:page], :per_page => 10, :joins => 'rating_statistics', :order => 'rating_avg') Mysql::Error: Unknown table 'images': SELECT `images`.* FROM `images` rating_statistics ORDER BY rating_avg LIMIT 0, 10 thanks, jp -- 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@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 -~----------~----~----~----~------~----~------~--~---