Eager Loading: Stacking Includes?

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

On 1/29/07, James [email protected] 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/Associations/ClassMethods.html
“Eager loading of associations” and “Table Aliasing”


Rick O.
http://weblog.techno-weenie.net
http://mephistoblog.com

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?

Thanks Rick, that solved my problem.

Bill, if you have nothing nice to say, please say nothing.