Heyo,<br><br>I have a table called Teams which I hope to hold multiple trees (using <span style="font-family: courier new,monospace;">:scope => :tree_id</span>).<br>My table looks like this...<br><br>ID NAME LFT RGT PARENT_ID TREE_ID<br>
17 My first team 1 6 NULL 17<br>18 Soon to break away 2 5 17 17<br>19 Child of soon to... 3 4 18 17<br>
<br><br>If I wanted to promote "Soon to break away" and make it a root I'd try something like...<br> >> t = Team.find(18)<br> >> t.move_to_right_of(17)<br> => #<Team id: 17, name: "My First Team", lft: 1, rgt: 2, parent_id: nil, lock_version: 1, created_at: "2008-03-24 13:27:30", updated_at: "2008-03-24 13:27:30", tree_id: 17><br>
<br>Now the table looks like...<br><br><br>ID NAME LFT RGT PARENT_ID TREE_ID<br>
17 My first team 1 2 NULL 17<br>
18 Soon to break away 3 6 NULL 17<br>
19 Child of soon to... 4 5 18 17<br><br>So since 18 is now a root...<br> I was expecting his lft to adjust itself to 1 and rght to adjust to maxright.<br> I was also expecting row 18 and 19 to adjust their tree_ids to 18.<br>
<br>Oy. Am I approaching this the wrong way?<br><br>-Stephen<br><br>