Hello All, I''m trying to determine an elegant way to do a nested group_by. What I would like to do is group records pulled from the database by one field and then another and display them in the view. Ideally it would look something like this: Controller: @groups = Record.all.group_by(&:field1).group_by(&:field2) In the View: <% @groups.each do | field1, group1 | %> <% field1 %> <% field2.each do | field2, group2 | <% field2 %> <% group2.each do |record| %> <% record.name %> <% end %> <% end %> I''ve been able to do the second group_by in the view code, flatten it into and array and then loop through it, but that seems hackish. What I''m shooting for is to allow the user to pick two fields to group by in a form submit and then print out a report with the data grouped in that way. Any thoughts? Thanks, Nick -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.