It appears that changeset 8 has broken the ability to create root nodes. I propose the following fix:
# on creation, set automatically lft and rgt to the end of the tree
def before_create
maxright = self.class.maximum(acts_as_nested_set_options[:right_column], :conditions => acts_as_nested_set_options[:scope])
0
# adds the new node to the right of all existing nodes
self[acts_as_nested_set_options[:left_column]] = maxright+1
self[acts_as_nested_set_options[:right_column]] = maxright+2
end
Attachments
- better_nested_set.rb (23.5 kB) - added by Tim Trautmann <timct@mac.com> on 08/25/06 00:18:09.
- change of before_create method
Change History
Download in other formats:
|