From: Jarrett Green Date: 2008-09-09T05:14:47+09:00 Subject: Re: Hash custom sort? Overriding <=>? Help! David A. Black wrote: > > Sorting and grouping aren't the same thing, but if you want grouping > by the results of the name method, you would do: > > @project_companies = @projects.group_by {|project| project.name } > > > Thanks for the response david! Unfortunately, I don't think this is what I was looking for. The key I need exists through an association. Calling project.name gives me the project's name, sure, and calling project.primary_company_id, gives me the foreign key id of a has_one relationship with Company. calling project.primary_company, through some rails magic gives me the entire object associated with that foreign key. I'd like that key to just be one parameter out of that relationship - the associated company's name, which was why I was asking if I could use @project_companies = @projects.group_by(&:primary_company.name). It seems to be an all or nothing. I can either have the foreign key integer, or the entire object, but not param from that object? -- Posted via http://www.ruby-forum.com/.