Michael Pavling wrote in post #975879: > > Comparing your solution to Tim's suggestion, I infer that you don't > have "client_category" as an association? (ie: client belongs_to > :category).
No, we do not have any association by that name. The data originates off site and we do not know what client_categories are even possible or what the codes mean. > You could use the "group_by" method for collections, and select the > first off each group - that saves you doing a query per client, at the > cost of doing one large query and a load of Ruby iteration. > > Client.all.group_by(&:client_category).map(&:first) Could you explain the '&:' idiom to me? I cannot seem to find any examples of it by googling. > > At the end of the day, you're in the realms of doing some fudging to > get the data out you're after (as you've discovered), as you're not > doing something that's a natural fit for the DB or ORM. Sorry if > that's not massively helpful... just letting you know we feel your > pain. Thanks. Misery shared is misery lessened. -- Posted via http://www.ruby-forum.com/. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.