What's the DM way to order results by an attribute of an association?

For example, "clients" are associated with "users" through
"user_client"s.
If we want to sort clients by the user_clients.updated_at field then
I'd try something like...

  @user.clients.all( :order => [ Client.user_clients.updated_at ] )

...but that resulted in an "Argument Error" (Full output at
http://pastie.org/840356).
Out of interest I also tried...

  @user.clients.all( :order =>
[ Client.user_clients.updated_at.desc ] )

...but that resulted in "undefined method `desc'"

I know we can achieve the desired result by providing our own sql
query but I'd like to use DM's power if possible.
Any ideas please? Many thanks,
George

Related thread: "Order by attributes of association"
http://groups.google.com/group/datamapper/browse_thread/thread/423b122d4f72b9db/2bc0738f2fda2ea4?lnk=gst&q=order#2bc0738f2fda2ea4

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to datamap...@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to