Sumeru Suresh
Sumeru Suresh

Reputation: 3181

Awesome nested set plugin - how to add new children to the tree at various levels

Hi I have a tree structure.. I am using Awesome nested set plugin. how to add nodes to the children at various levels. Please help me. I want to add ,edit and delete nodes at any levels.

Can anyone help me for the same?

Upvotes: 3

Views: 1221

Answers (1)

Horacio
Horacio

Reputation: 2765

To add a children simply call

item.children.create(:name => "new item")

or

new_item = Item.new(:name => "new item")
item.children << new_item

You can find all the methods to manipulate the nested model at the plugin source code 1

http://github.com/collectiveidea/awesome_nested_set/blob/master/lib/awesome_nested_set.rb

Upvotes: 3

Related Questions