Forum: Ruby on Rails Eager Loading: Stacking Includes?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E32bd3dfd91ea3229e9fd13371129fd3?d=identicon&s=25 James (Guest)
on 2007-01-30 00:03
Is it possible to stack :include's in a situation like this:

A has_many Bs

B belongs_to A
B has_many Cs

C belongs_to B


The result of the query looking something like...

A.id  B.id  C.id
0     0     0
0     0     1
0     0     2
0     1     0
...
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2007-01-30 01:17
(Received via mailing list)
On 1/29/07, James <rails-mailing-list@andreas-s.net> wrote:
>
> Is it possible to stack :include's in a situation like this:
>
> A has_many Bs
>
> B belongs_to A
> B has_many Cs
>
> C belongs_to B

Something like...

:include => { :bs => { :a => [], :cs => [:b]} }

http://rails.rubyonrails.org/classes/ActiveRecord/...
"Eager loading of associations" and "Table Aliasing"

--
Rick Olson
http://weblog.techno-weenie.net
http://mephistoblog.com
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2007-01-30 02:14
(Received via mailing list)
Hi James,

James wrote:

> Is it possible to stack :include's in a situation like this:

Stack?

> The result of the query looking something like...

Looks like?  Is supposed to look like?  I wish it looked like?
E32bd3dfd91ea3229e9fd13371129fd3?d=identicon&s=25 James (Guest)
on 2007-01-30 16:17
Thanks Rick, that solved my problem.

Bill, if you have nothing nice to say, please say nothing.
This topic is locked and can not be replied to.