Acts_as_nested_set does not work (in my case)


I am using acts_as_nested_set. My problem is that the columns “lft” and
“rgt” get the value 0 if I create a new entity. If I delete an entity I
get negative values (-1, -2, -3) - but for all entities. Is there
anything missing? Is there any example for “acts_as_nested_set” in the


When you create a new object it does not kick in. It does when you add a
child to another object. Then the nested set can actually work its

p = Category.create :title => “Parent”
c = Category.create :title => “Child”
p.add_child c

p.lft --> 1
p.rgt --> 4
c.lft --> 2
c.rgt --> 3

Hope that helps,

Adrian M.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs