/ Published in: Rails
Allows iteration through the main array, with subarrays with the records for each group.
Expand |
Embed | Plain Text
User.order(:country_id).group_by(&:country_id).each { |country| country.each { |usergroup| if usergroup.is_a?(Array) then usergroup.each { |user| puts user.name } else puts Country.find(usergroup).name end }}
Comments
Subscribe to comments
You need to login to post a comment.

Will return something like:
IRELAND johnny patricia yolanda Katie Michelle ITALY jerry