开发者

What is the correct way to remove a node from a tree managed by awesome_nested_set?

开发者 https://www.devze.com 2023-03-07 23:53 出处:网络
It is unclear how to correctly remove a node or set of nodes from a tree managed by awesome_nested_set.

It is unclear how to correctly remove a node or set of nodes from a tree managed by awesome_nested_set.

Given a parent node and a child node, I've tried

parent.children.clear

however, th开发者_如何学Gois then leaves the tree in a state such that I can't re-add the child back to the parent object.

Do I have to explicitly null out all of the lft, rgt, and parent_id columns?


The OP wrote:

Further research shows that if I do child.update_attribute(:parent_id, nil) and reload both parent and child, that seems to work.

0

精彩评论

暂无评论...
验证码 换一张
取 消