# Acts\_as\_tree? Heirarchy needed

**URL:** <https://www.ruby-forum.com/t/acts-as-tree-heirarchy-needed/155306>\
**Category:** Rails\
**Created:** [December 10, 2008, 1:10pm UTC](https://www.ruby-forum.com/t/acts-as-tree-heirarchy-needed/155306 "2008-12-10T13:10:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iain\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@Iain\_A](https://www.ruby-forum.com/u/Iain_A)\
**Post date:** [December 10, 2008, 1:10pm UTC](https://www.ruby-forum.com/t/acts-as-tree-heirarchy-needed/155306/1 "2008-12-10T13:10:58Z")

</div>

Hello,

I have a problem that I thought I could solve with acts\_as\_tree but  
I’m thinking now that acts\_as\_tree doesn’t quite fit the bill.

Basically I have a standard hierarchy with 1 difference:

Node 1  
\ Leaf 1  
\ Node 2  
\ Leaf 2  
\ Node 3  
\ Leaf 3  
\ Link back to Node 3 \*\*\*\* HARD BIT

* * *

```
                             \ Node 4
                                          \ Leaf 4
                                          \ Leaf 5

```

The problem is Node 3’s parent is Node 2 so linking back to Node 3 is  
impossible.

i.e

node3.children.create(node5)  
node5.children \<\< node 3 – This will cause node3’s parent\_id be  
node5 and not node 2

Can anyone think of a way to do this??

Thanks

Iain
