I have 3 models, requests, listings, and users.
requests belong to listings and users
listings belong to users
I have the associations all properly set up, so that is not the problem
What I am trying to do is sort a list of requests by
requests.listings.users
My find (that doesn’t work) is similar to this.
Request.find(:all, :include => [:listing, :user], :order => "
requests.listings.user.username", :limit => 20)
Some things I’ve thought about… listing and request both belong to the
same users table, so my include is probably fine. But I know that my
order
statement is wrong… to sort by requests.users.username I just use "
users.username", but for requests.listings.users.username I can’t use "
listings.users.username" because it doesn’t work, and “users.username”
isn’t
sorting by the right thing. Any clues?
Thanks in advance,
–Tyler P.