Ticket #8 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Changeset 8 breaks root node creation

Reported by: Tim Trautmann <timct@mac.com> Assigned to: somebody
Priority: major Milestone: 0.1 with tests
Component: plugin Version: 0.1
Keywords: Cc:

Description

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

08/25/06 00:18:09 changed by Tim Trautmann <timct@mac.com>

  • attachment better_nested_set.rb added.

change of before_create method

08/25/06 00:19:33 changed by Tim Trautmann <timct@mac.com>

The above description ate the crutial "or" operator between

maxright = self.class.maximum(acts_as_nested_set_options[:right_column], :conditions => acts_as_nested_set_options[:scope])

and

0

I have attached the fixed file. Feel free to diff for patching.

08/29/06 16:45:12 changed by jcm

  • status changed from new to closed.
  • resolution set to fixed.

Thks, youre right ! I definitely need extensive tests...

Would you accept to contribute a little to this, at least a textual list of all tests to make ? (open a new ticket for tests).

10/10/06 13:30:55 changed by jcm

  • version set to 0.1.
  • component changed from component1 to plugin.
  • milestone set to 0.1 with tests.