Preloading child rows just a level deeper

hiho.

following problem.
i have 3 tables in my database with each representing an object.
lets say
A belongs_to B belongs_to C.

when i do
my_a = A.find(:all)
i can access B as my_a.b and C as my_a.b.c
thats fine but rails querys the database each time i do that

so is use
my_a = A.find(:all, :include => :b)
works fine for my_a.b but not for my_a.b.c

so i tried
my_a = A.find(:all, :include => [:b, :c])
but that gives an error:
“Association named ‘c’ was not found; perhaps you misspelled it?”

well, no i didnt misspelled, but table A dont has an c_id. only table B
knows to what c it belongs
no wonder there is an error … :confused:

question is:
Can i preload the rows of C like i do it with the rows in B when i query
table A?

i hope i made it clear enough… :confused:

[ No, i cant/dont want to use STI ]

Gerald,

Try googling for ‘rails bottomless eager loading’–new feature in 1.1,
I believe.

Ed Frederick - edwardfrederick.com

To follow up my previous reply:

try: A.find(:all, :include => { :b => { :c })

thank you so much!
awesome!!!