# Acts\_as\_family\_tree

**URL:** <https://www.ruby-forum.com/t/acts-as-family-tree/100193>\
**Category:** Rails\
**Created:** [February 2, 2006, 2:55am UTC](https://www.ruby-forum.com/t/acts-as-family-tree/100193 "2006-02-02T02:55:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_Daggett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@M\_Daggett](https://www.ruby-forum.com/u/M_Daggett)\
**Post date:** [February 2, 2006, 2:55am UTC](https://www.ruby-forum.com/t/acts-as-family-tree/100193/1 "2006-02-02T02:55:22Z")

</div>

For a project that I am working on I need to have a family tree. This  
means that instead of having one parent each item has at most two. As  
far as I know acts\_as\_tree only allows one parent\_id. Any suggestions  
on how to make a “acts\_as\_family\_tree” ?

Thanks,  
Mark

–

---

<div class="post-metadata">

**Author:** ![M\_Daggett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@M\_Daggett](https://www.ruby-forum.com/u/M_Daggett)\
**Post date:** [February 2, 2006, 5:16pm UTC](https://www.ruby-forum.com/t/acts-as-family-tree/100193/2 "2006-02-02T17:16:00Z")

</div>

Hi Alex,  
Yes, I have HATBM right now but I was hoping to leverage off of the  
acts\_as\_tree helper methods like node.ancestors, node.siblings,  
node.children etc. I don’t think it would be that bad to extend  
acts\_as\_tree to work as a family tree as well. If I find a nicely  
encapsulated solution I’ll release it as a plugin too.

Mark

On 2/2/06, Alex Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> –  
> Alex
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–

---

<div class="post-metadata">

**Author:** ![M\_Daggett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@M\_Daggett](https://www.ruby-forum.com/u/M_Daggett)\
**Post date:** [February 2, 2006, 6:19pm UTC](https://www.ruby-forum.com/t/acts-as-family-tree/100193/3 "2006-02-02T18:19:36Z")

</div>

M Daggett wrote:

> Hi Alex,  
> Yes, I have HATBM right now but I was hoping to leverage off of the  
> acts\_as\_tree helper methods like node.ancestors, node.siblings,  
> node.children etc. I don’t think it would be that bad to extend  
> acts\_as\_tree to work as a family tree as well. If I find a nicely  
> encapsulated solution I’ll release it as a plugin too.

Please do! I’d be intrigued.

---

<div class="post-metadata">

**Author:** ![M\_Daggett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@M\_Daggett](https://www.ruby-forum.com/u/M_Daggett)\
**Post date:** [February 2, 2006, 10:23am UTC](https://www.ruby-forum.com/t/acts-as-family-tree/100193/4 "2006-02-02T10:23:11Z")

</div>

M Daggett wrote:

> For a project that I am working on I need to have a family tree. This  
> means that instead of having one parent each item has at most two. As  
> far as I know acts\_as\_tree only allows one parent\_id. Any suggestions  
> on how to make a “acts\_as\_family\_tree” ?  
> Better to HABTM onto the item table, surely? That way there’s no  
> problem expanding out to adoptive and natural parents, step-parents, and  
> so on?
