On Jan 18, 11:20 pm, James Byrne <li...@ruby-forum.com> wrote:
> Michael Pavling wrote in post #975879:

> > 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.

foo(&:bar) is basically short hand for foo {|f| f.bar}. You'll
probably get more google hits by searching for Sym to_proc

Fred
>
>
>
> > 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 viahttp://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.

Reply via email to