On Thu, Aug 12, 2010 at 4:49 PM, Mohammed Alenazi <vb4...@gmail.com> wrote:
> @users = User.paginate :joins => :properties ,:select => > 'users.*', :page => params[:page], :order => 'count(properties.id) > DESC',:conditions => ['users.id != 1','users.id=properties.user_id'] > > this the error message i got > misuse of aggregate: count(): SELECT users.* FROM "users" INNER > JOIN "properties" ON properties.user_id = users.id WHERE (users.id != > 1) ORDER BY count(properties.id) DESC LIMIT 10 OFFSET 0 No kidding :-) `count(*)` gives you a single number, so you couldn't possibly do an ORDER BY with it. Just an ORDER BY properties.id should do what you want. Of course, I have to wonder if this couldn't be done much more neatly with a named scope or two, particularly that "users.id != 1" business... FWIW, -- Hassan Schroeder ------------------------ hassan.schroe...@gmail.com twitter: @hassan -- 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-t...@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.