The problem has been solved by adding a counter column to the users
table

On Aug 13, 7:16 pm, Mohammed Alenazi <vb4...@gmail.com> wrote:
> thank you for your responses. Actually what I wanted is to show the
> users based on how many properties they have. Something like
> @users = User.all(:include => :properties, :order =>
> 'count(properties.id) DESC')
> If you look it my first post, I have the a statement working for mySql
> but not in postgre
>
> On Aug 13, 8:52 am, Hassan Schroeder <hassan.schroe...@gmail.com>
> wrote:
>
> > On Thu, Aug 12, 2010 at 11:25 PM, Mohammed Alenazi <vb4...@gmail.com> wrote:
> > > There is still a problem.
> > > �...@users = User.paginate :joins => :properties ,:select => 'distinct
> > > users.*', :page => params[:page], :order => 'properties.id
> > > DESC',:conditions => ['users.id != 1']
> > > I got this error message.
> > > ActiveRecord::StatementInvalid (PGError: ERROR:  for SELECT DISTINCT,
> > > ORDER BY expressions must appear in select list
> > > : SELECT distinct users.* FROM "users"   INNER JOIN "properties" ON
> > > properties.user_id = users.id  WHERE (users.id != 1)  ORDER BY
> > > properties.id DESC LIMIT 10 OFFSET 0):
>
> > Leaving out pagination and the "users.id != 1" stuff for the moment --
> > does something like
> > @users = User.all(:include => :properties, :order => 'properties.id DESC')
> > give you the expected data result?
>
> > --
> > 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.

Reply via email to