# Eager loading with acts\_as\_tree

**URL:** <https://www.ruby-forum.com/t/eager-loading-with-acts-as-tree/88439>\
**Category:** Rails\
**Created:** [March 11, 2007, 2:29am UTC](https://www.ruby-forum.com/t/eager-loading-with-acts-as-tree/88439 "2007-03-11T02:29:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RSElliott\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b487fb/32.png) [@RSElliott\_M](https://www.ruby-forum.com/u/RSElliott_M)\
**Post date:** [March 11, 2007, 2:29am UTC](https://www.ruby-forum.com/t/eager-loading-with-acts-as-tree/88439/1 "2007-03-11T02:29:53Z")

</div>

Sigh, I have a new problem every day.

Okay I have a model that acts\_as\_tree, so I am trying to eager load the  
objects + all of their children, plus their children’s children, and so  
on. However, :include =\> :children alone doesn’t do this, and so far  
I’ve got something like:

:include =\> [{:children =\> [{:children =\> [:children, :upload]},  
:upload]}, :upload, :tags])

Is that not absurd or what? It’s so far the only way I can avoid  
queries during rendering. Unfortunately that assumes the depth of the  
tree, when in actuality it can be far greater.

Should I limit the depth of the tree? This is for a discussion forum of  
sorts. I don’t know if it’s typical to have potentially infinite tree  
depth in threaded forums.

Should I even worry about pre-loading all data before rendering or just  
go with the flow? I’d like to cut down on the number of queries if  
possible.
