Best way to eager load accross multiple relationships?

Let’s say I have Departments, which have many Persons , which have many
Pets.

I can fetch Departments and eagerly load their Persons, with :include=>
in the find statement.

But what if I want to eagerly load all the Persons, and all of the
Persons’ Pets, in, if not one single db trip, then maybe in two? In as
few as possible.

I don’t think I can do this with stock :include. Does anyone have any
advice as to how I might be able to accomplish this?

Thanks,
Jonathan

you’ll want to read this…
http://snippets.dzone.com/posts/show/2089

On Aug 2, 1:38 pm, Jonathan R. <rails-mailing-l…@andreas-

Wow, awesome, perfect! I had no idea a nested include was possible. That
solves so many things.

[If I wanted to actually document this, and submit it as a patch to the
official documentation… how would I do this?]

vincent fazio wrote:

you’ll want to read this…
http://snippets.dzone.com/posts/show/2089

On Aug 2, 1:38 pm, Jonathan R. <rails-mailing-l…@andreas-

On Aug 2, 2007, at 2:04 PM, Jonathan R. wrote:

Wow, awesome, perfect! I had no idea a nested include was possible.
That
solves so many things.

[If I wanted to actually document this, and submit it as a patch to
the
official documentation… how would I do this?]

http://api.rubyonrails.org/classes/ActiveRecord/Associations/
ClassMethods.html

vincent fazio wrote:

you’ll want to read this…
http://snippets.dzone.com/posts/show/2089

That’s where the documentation changes would go, but you’d open a
ticket to add your [PATCH].

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

On 8/2/07, Jonathan R. [email protected] wrote:

[If I wanted to actually document this, and submit it as a patch to the
official documentation… how would I do this?]

watch this screen cast


Edward Grant
[email protected]

RPGA #342155
CAMARILLA #US2002022579