Acts_as_nested_set does not work (in my case)


#1

Hello,

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
web?


#2

Oliver,

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
magic.

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.