Open kinman-enphase opened 9 years ago
before_destroy :move_children , prepend: true
but the code is actually bad because that won't update the hierarchy table
Delete the before_destroy
and the default https://github.com/mceachen/closure_tree#available-options of :nullify
will do what you want.
:nullify isn't what I want. I want to move the children to the parent of this tree. :nullify simply removes the parent_id, which makes the children roots rather than children of different node.
That not what he want , he want to make the root to adopt the orphans.
On Ruby 2.2.2 and Rails 4.0.10: Before destroying a node, I want to move its children to the root node of the tree.
self.root.id
throws an exception becauseself.root
is nil. If I access it from within the corresponding controller, I can reach it, but I prefer to put this logic in the model.