On Sep 11, 2011, at 11:45 AM, John Merlino wrote:
thanks for response. What you said explained a lot.
Now I have never seen rails code written like that. Would it have been
better to do this:
@b.map(&:a_group).compact.uniq
That would load up all of the elements -- whether they matched (not
nil) or not, and then filter them, so it's kind of wasteful. Doing it
all in Arel like that means that when the final SQL is compiled out of
your Ruby method chain, the actual request to the DB will only return
the resources you wanted, rather than also returning non-matching
results.
Walter
--
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.