Eager Loading: Stacking Includes?


#1

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


#2

On 1/29/07, James removed_email_address@domain.invalid 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


#3

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?


#4

Thanks Rick, that solved my problem.

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