On Jun 9, 2011, at 8:32 AM, Jacob Basham wrote:
> Howdy!
> 
> I have n through an association, but when I try to order them they get
> grouped by the through association. Is there a way to get them ordered
> without the grouping?

You may have come to this on your own, but I was curious, so i ran a few tests. 
You can see my setup here:
https://gist.github.com/1017306

Summary: 
DM doesn't correctly infer the necessary joins to enable ordering, so you have 
to explicitly declare the necessary links to use when ordering through an 
association (links are inverse relationships *back* to your source model). For 
example:

  `Author.all(:order => Author.comments.created_at.asc, :links => 
[Author.relationships[:comments].inverse])`

This could, of course, be wrapped in a class method on Author to move the noise 
somewhere harmless (eg., `Author.by_comment_created_at_asc` or something).

HTH,
Emmanuel

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

Reply via email to