Robert Head
2007-Jan-30 20:01 UTC
[Betternestedset-talk] Assuring initialization of lft and rgt
I''m having trouble setting lft and rgt for root nodes. With betternestedset, you can''t access lft and rgt, you have to use move_to_* But using move_to_* when lft or rgt is nil results in an exception. "You cannot move a node if left or right is nil /Users/roberthead/Documents/Projects/icrew_machine/config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:427:in `move_to'' /Users/roberthead/Documents/Projects/icrew_machine/config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:421:in `move_to_child_of''..." What am I missing? Many thanks in advance. Robert Head robert.head at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20070130/e3c0c644/attachment.html
Krishna Dole
2007-Jan-30 20:21 UTC
[Betternestedset-talk] Assuring initialization of lft and rgt
Hi Robert, The lft and rgt values are set for new records when they are saved: i = Item.new # lft and rgt are nil i.save # lft = 1, rgt = 2 if you have a table with preexisting records that don''t have lft or rgt, you can use the SetClass.renumber_all method to get things fixed up. (Note that if you have multiple trees, you need to make sure that all members of each tree have the same scope value before doing this). Cheers, Krishna On 1/30/07, Robert Head <robert.head at gmail.com> wrote:> I''m having trouble setting lft and rgt for root nodes. > > With betternestedset, you can''t access lft and rgt, you have to use > move_to_* > > But using move_to_* when lft or rgt is nil results in an exception. > > "You cannot move a node if left or right is nil > /Users/roberthead/Documents/Projects/icrew_machine/config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:427:in > `move_to'' > /Users/roberthead/Documents/Projects/icrew_machine/config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:421:in > `move_to_child_of''..." > > What am I missing? > > Many thanks in advance. > > Robert Head > robert.head at gmail.com > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > >