On Mar 2, 6:03 am, Josiah <[email protected]> wrote:
> What is the api for grouping by and sorting by a joined table in 1.1?
>
> eg:
>
> Foo.all( ... ).group_by(&:'joinedtable.some_field')
I'm not convinced this a datamapper method ... #group_by is provided
by activesupport, and you're using it with a proc. This happens in
ruby land, not in the DB, meaning you can do this:
.group_by {|record| record.joined_table.some_field }

>
> and
>
> Foo.all(order: [ :'joined_table.some_field'.asc ])
Foo.all(
  order: Foo.joined_table.some_field.asc,
  links:  [relationships['joined_table'].inverse]
)

(There is small chance I didn't get this fix merged in for 1.1, in
that case here is a hack to you can use to work around:
http://rhnh.net/2010/12/01/ordering-by-a-field-in-a-join-model-with-datamapper)

Cheers,
Xavier

>
> Thanks,
> Josiah

-- 
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