Forum: Ruby on Rails acts_as_nested_set does not work (in my case).

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Oliver P. (Guest)
on 2006-05-10 22:27

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
Adrian M. (Guest)
on 2006-05-11 08:27
(Received via mailing list)

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 topic is locked and can not be replied to.