开发者

What is the correct way to remove a node 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜