Just wondering if this can go more than one level deep some how? For example.. Customers have [0,many] items.. items have [0,many] destinations.. So, with eager associations, it''s easy to get a customer and all of his items in one swoop.. SWEET btw.. But, what about each item''s destinations? Can it extend to soemthing like this also in one swoop? customer.each do |c| c.items.each do |i| i.destinations.each do |d| .. end end end And, if so, how? Thanks! --Steve
On 4/24/05, Stephen Waits <swaits-g8GSkY9QmIteoWH0uzbU5w@public.gmane.org> wrote:> > Just wondering if this can go more than one level deep some how?That''s also something I could have used yesterday. I think I saw someone on IRC (or was it on this list?) propose to define in the ActiveRecord class which related objects should be automatically loaded. That could have been the solution in my case, but I don''t know if it has been implemented. Raph> > For example.. > > Customers have [0,many] items.. items have [0,many] destinations.. > > So, with eager associations, it''s easy to get a customer and all of his > items in one swoop.. SWEET btw.. > > But, what about each item''s destinations? Can it extend to soemthing like > this also in one swoop? > > customer.each do |c| > c.items.each do |i| > i.destinations.each do |d| > .. > end > end > end > > And, if so, how? > > Thanks! > > --Steve > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Sun, 24 Apr 2005, Raphael Bauduin wrote:> On 4/24/05, Stephen Waits <swaits-g8GSkY9QmIteoWH0uzbU5w@public.gmane.org> wrote: >> >> Just wondering if this can go more than one level deep some how? > > That''s also something I could have used yesterday.What''s already there is very handy.. somehow magical. This would just take it a step further. Anyone know if this is implemented? --Steve
On 4/25/05, Stephen Waits <swaits-g8GSkY9QmIteoWH0uzbU5w@public.gmane.org> wrote:> > >> Just wondering if this can go more than one level deep some how? > > > > That''s also something I could have used yesterday. > > What''s already there is very handy.. somehow magical. This would just > take it a step further. Anyone know if this is implemented? >I don''t think this will be implemented. Defining an association doesn''t mean you actually need all objects in any case. It would mean querying the database and joining all the associated tables even if you don''t actually need them. A great performance slowdown and a waste of resources IMHO. -- Best Karol Hosiawa
On Mon, 25 Apr 2005, Karol Hosiawa wrote:> I don''t think this will be implemented. Defining an association doesn''t > mean you actually need all objects in any case. It would mean querying > the database and joining all the associated tables even if you don''t > actually need them. A great performance slowdown and a waste of > resources IMHO. -- Best Karol HosiawaWell, just like current "eager" loading - it''d be on demand. When you do need it, it''s really convenient - just turn it on. When you don''t need it - you don''t do anything.. --Steve