Sorting with Associations ??

With ActiveRecord, how do I sort results using associations?

For example, I have

class Roster < ActiveRecord   # name => text   has_many :members end class Member < ActiveRecord   # zip_code => integer   belongs_to :roster end

I would like to generate a list of members, grouped by roster name, sub-sorted by zip code.

Something like this: Member.order("roster.name, zip_code").all

But I can't get the syntax quite right - I've played around with join and include - can anyone tell me the right syntax to use??

thanks, Andy

Remember that table names are plural.

Member.joins(:roster).order("rosters.name, zip_code")

That did it ! Thank you very much !!!!!