# Active Record acts\_as\_tree and leaf depth

**URL:** <https://www.ruby-forum.com/t/active-record-acts-as-tree-and-leaf-depth/80366>\
**Category:** Rails\
**Created:** [December 25, 2006, 8:05am UTC](https://www.ruby-forum.com/t/active-record-acts-as-tree-and-leaf-depth/80366 "2006-12-25T08:05:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@Tony\_K](https://www.ruby-forum.com/u/Tony_K)\
**Post date:** [December 25, 2006, 8:05am UTC](https://www.ruby-forum.com/t/active-record-acts-as-tree-and-leaf-depth/80366/1 "2006-12-25T08:05:19Z")

</div>

Using acts\_as\_tree, is it possible to get information of the depth a  
tree leaf in relation to the root? Or is available to derive  
information to save in the way “position” can be derived and saved for  
acts\_as\_list.

---

<div class="post-metadata">

**Author:** ![Tony\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@Tony\_K](https://www.ruby-forum.com/u/Tony_K)\
**Post date:** [December 25, 2006, 12:13pm UTC](https://www.ruby-forum.com/t/active-record-acts-as-tree-and-leaf-depth/80366/2 "2006-12-25T12:13:39Z")

</div>

Hi Tony,

Le 25 déc. 06, à 08:03, Tony K. a écrit :

> Using acts\_as\_tree, is it possible to get information of the depth a  
> tree leaf in relation to the root? Or is available to derive  
> information to save in the way “position” can be derived and saved for  
> acts\_as\_list.

It cannot be done simply. Check nested\_set instead, where this info is  
simple to retrieve.

## Jean-Christophe M.

> **[Édition et distribution de livres sur la musique, de partitions et de revues...](https://symetrie.com/fr)**
>
> Présentation des publications de Symétrie en musique, musicologie et médecine de la voix.

Better Nested Set for rails:  
[http://opensource.symetrie.com/trac/better\_nested\_set](http://opensource.symetrie.com/trac/better_nested_set)

---

<div class="post-metadata">

**Author:** ![Tony\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@Tony\_K](https://www.ruby-forum.com/u/Tony_K)\
**Post date:** [December 25, 2006, 9:04pm UTC](https://www.ruby-forum.com/t/active-record-acts-as-tree-and-leaf-depth/80366/3 "2006-12-25T21:04:14Z")

</div>

Thanks for the response. I will look in nested\_set.

Can a table using acts\_as\_tree be used in combination with single  
table inheritance as described in the book Agile Web D. with  
Rails, pg. 263?
