closure_tree icon indicating copy to clipboard operation
closure_tree copied to clipboard

Improve documentation to clarify reparenting

Open ruok5 opened this issue 11 years ago • 2 comments

I spent a little time working out a before_save callback to handle assigning nodes to a new parent node when the object's parent_id had been changed. Of course, I got an endless loop, resulting in neat SystemStackError, "stack level too deep".

When I removed the callback, and just allowed the record to save normally, I discovered that closure_tree was already doing all of the work for me, to my delight (though not really surprise, given how well thought-out this gem is).

I think it would be helpful to mention in the README under the "Moving nodes around the tree" section that if you're working with parent_id directly (like in a <form>``<select>, as I am), it just works.

ruok5 avatar Nov 05 '14 19:11 ruok5

That sounds very helpful. Do you want to suggest the edits to the readme in a pull request? (You should be able to just click the edit button).

Thanks for taking the time to open this issue.

mceachen avatar Nov 05 '14 20:11 mceachen

another README.md fix

j = Tag.find 102
j.self_and_ancestor_ids
=> [102, 87, 77]
j.update parent_id: 96
j.self_and_ancestor_ids
=> [102, 96, 95, 78]

should the last array look like this [102, 87, 77, 96] ?

mibamur avatar Aug 27 '16 22:08 mibamur