[Betternestedset-talk] Virtual roots

Krishna Dole dontfall at gmail.com
Thu Jul 5 08:53:09 EDT 2007


yes and yes. currently nodes cannot be moved between trees (though
this behavior could be added). the (admittedly klunky) workaround is
to delete the node from one tree and create it in another.

krishna

On 7/5/07, Mikel Lindsaar <raasdnil at gmail.com> wrote:
> I've got a tree with virtual roots scoped on a foreign_id key.
>
> This works.
>
> However, if I try to move a root to the child of another node, I get
> the following error (pasted below).
>
> Is this correct behaviour?  Does this mean once you create a node, it
> can not move into another tree?
>
> If this is the case... does that mean the only way to move a node into
> another tree is to delete and re-create it?
>
> Thanks
>
> Mikel
>
> Error follows:
>
> ?> p1
> => #<Paragraph:0x3565150 @attributes={"text"=>nil, "section_id"=>"1",
> "lft"=>"1", "id"=>"1", "parent_id"=>nil, "rgt"=>"2"}>
> >> p2
> => #<Paragraph:0x3553b30 @attributes={"text"=>nil, "section_id"=>"2",
> "lft"=>"1", "id"=>"2", "parent_id"=>nil, "rgt"=>"2"}>
> >> p2.move_to_child_of(p1.id)
> ActiveRecord::ActiveRecordError: Impossible move, target node cannot
> be inside moved tree.
>         from ./script/../config/../config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:933:in
> `move_to'
>         from ./script/../config/../config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:1109:in
> `with_optional_transaction'
>         from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/database_statements.rb:59:in
> `transaction'
>         from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:95:in
> `transaction'
>         from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:121:in
> `transaction'
>         from ./script/../config/../config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:1109:in
> `with_optional_transaction'
>         from ./script/../config/../config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:924:in
> `move_to'
>         from ./script/../config/../config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:865:in
> `move_to_child_of'
>         from (irb):68
> >>
> _______________________________________________
> Betternestedset-talk mailing list
> Betternestedset-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/betternestedset-talk
>


More information about the Betternestedset-talk mailing list