Topic: :order => by a has_many relationship?
Hey, this is probably a simple question that has been answered before but I can't seem to find a solution to it. I have two objects, lets call them Item and Owner. The relationships are:
item belongs_to owner
owner has_many item
I have foreign keys set up, everything works etc.
What if I want to sort my items, but owner.full name? I can't use :order => 'owner.full_name' because that is throwing that into raw MySQL, which obviously doesn't take Rails relationships.
I see there is an order command that you can specify in the model when you set the relationship. I have not tinkered with it because I have the following issue with it: If I set this to order => full_name, what happens if later on I want to sort by order => age?
I'm probably missing something crucial here along the way...am I?