ordering a collection by an association's property
- by neiled
class Person
belongs_to :team
class Status
#has last_updated property
class Team
has_many :members, :class => "Person"
Ok, so I have a Team class which has many People in it and each of those people has a status and each status has a last_updated property.
I'm currently rendering a partial with a collection similar to:
=render :partial => "user", :collection => current_user.team.members
Now how do I go about sorting the collection by the last_updated property of the Status class?
Thanks in advance!
p.s.
I've just written the ruby code from memory, it's just an example, it's not meant to compile but I hope you get the idea!