Ticket #40: callback_fixes.patch
| File callback_fixes.patch, 1.7 kB (added by rails, 1 year ago) |
|---|
-
vendor/plugins/better_nested_set/lib/better_nested_set.rb
old new 70 70 include SymetrieCom::Acts::NestedSet::InstanceMethods 71 71 extend SymetrieCom::Acts::NestedSet::ClassMethods 72 72 73 before_create :add_new_node 74 before_destroy :delete_all_children 75 73 76 # adds the helper for the class 74 77 # ActionView::Base.send(:define_method, "#{Inflector.underscore(self.class)}_options_for_select") { special=nil 75 78 # "#{acts_as_nested_set_options[:text_column]} || "#{self.class} id #{id}" … … 149 152 end 150 153 151 154 # On creation, automatically add the new node to the right of all existing nodes in this tree. 152 def before_create # already protected by a transaction155 def add_new_node # already protected by a transaction 153 156 maxright = base_set_class.maximum(right_col_name, :conditions => scope_condition) || 0 154 157 self[left_col_name] = maxright+1 155 158 self[right_col_name] = maxright+2 156 159 end 157 160 158 161 # On destruction, delete all children and shift the lft/rgt values back to the left so the counts still work. 159 def before_destroy# already protected by a transaction162 def delete_all_children # already protected by a transaction 160 163 return if self[right_col_name].nil? || self[left_col_name].nil? 161 164 self.reload # in case a concurrent move has altered the indexes 162 165 dif = self[right_col_name] - self[left_col_name] + 1
