Imagine Parent and Child classes as you might expect:

class Parent
  include DataMapper::Resource

  property :id, Serial
  property :name, String, :required => true

  has n, :children, :order => :age.desc   #Note default order by age 
descending (i.e. oldest to youngest)
end

class Child
  include DataMapper::Resource

  property :id, Serial
  property :name, String, :required => true
  property :age, String, :required => true

  belongs_to :parent
end

I now want the names of the kids from oldest to youngest so I do this

parent.children.name

The problem is that the order by age descending isn't being applied; in 
fact, it is ignored. I am getting the names sorted by id.

Is it even possible to maintain order across associations? If so, how?

Thanks.


-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/datamapper/-/EWGWK9_yVvsJ.
To post to this group, send email to datamapper@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