On 20 May 2010 16:59, Sharagoz <[email protected]> wrote:
> On May 20, 4:13 pm, Michael Pavling <[email protected]> wrote:
>> You need to iterate over a's bs [1] collection, and return the related
>> cs.
>
> I don't think that is necessary. It should be possible to get the data
> in a single sql query.
> @cs = C.all(:joins => {:b => :as}, :conditions => {'as.id = 1'})

If you don't have any info apart from a_id (in params, maybe), then
yes, go query the DB in one hit. But if you already have your 'a'
eager-loaded with all its related bs and cs, then there's not much
sense in rebuilding a load of objects; you might as well just select
them out of the collections you have in memory.
Depends on your starting point.

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to