acts_as_nested_set, delete(node) method?

Hello, I'm using acts_as_nested_set, and I can create root-nodes and add childs to it. No problem. But what can I do, to delete a certain node and all of it's children? And of course in a way that it's consistent, this means that the lft/rgt structure is still consistent. I'm using awesome nested set, but I can't find a method that is doing this. Or am I blind? At least I couldn't find it here

http://wiki.github.com/collectiveidea/awesome_nested_set/awesome-nested-set-cheat-sheet

Thx...

Hello, I'm using acts_as_nested_set, and I can create root-nodes and add childs to it. No problem. But what can I do, to delete a certain node and all of it's children? And of course in a way that it's consistent, this means that the lft/rgt structure is still consistent. I'm using awesome nested set, but I can't find a method that is doing this. Or am I blind? At least I couldn't find it here

http://wiki.github.com/collectiveidea/awesome_nested_set/awesome-nested-set-cheat-sheet

Just destroy the object like you would any other AR object.

Keep this in mind as well (an option to the acts_as_nested_set call in your model).

* +:dependent+ - behavior for cascading destroy. If set to :destroy, all the          # child objects are destroyed alongside this object by calling their destroy          # method. If set to :delete_all (default), all the child objects are deleted          # without calling their destroy method.

Philip Hallstrom wrote:

http://wiki.github.com/collectiveidea/awesome_nested_set/awesome-nested-set-cheat-sheet

Just destroy the object like you would any other AR object.

Keep this in mind as well (an option to the acts_as_nested_set call in your model).

* +:dependent+ - behavior for cascading destroy. If set to :destroy, all the          # child objects are destroyed alongside this object by calling their destroy          # method. If set to :delete_all (default), all the child objects are deleted          # without calling their destroy method.

Ok, destroy is what I'm looking for. Thx :wink: I can now delete all the childs of a certain node in the database. Is it also possible, to delete certain nodes from a nested set, when the nested set is in an array? After an:

@project = Project.find(:all)

in the console, I have all my projects in @project. I just want to delete now certain nodes (like id 4 and 5 or just node 6). I need this, because I want to create certain views on the nested set. But the destroy should only be done in this variable, not in the database.

@project.destroy(5)

NoMethodError: undefined method `destroy' for #<Array:0x4eef268>         from (irb):11         from :0

Even find does not work:

@project.find(5)

LocalJumpError: no block given         from (irb):8:in `find'         from (irb):8:in `each'         from (irb):8:in `find'         from (irb):8