Method deprecated or moved
This method is deprecated or moved on the latest stable version.
The last existing version (v1.2.6) is shown here.
before_destroy()
public
Prunes a branch off of the tree, shifting all of the elements on the right
back to the left so the counts still work.
# File activerecord/lib/active_record/acts/nested_set.rb, line 199
def before_destroy
return if self[right_col_name].nil? || self[left_col_name].nil?
dif = self[right_col_name] - self[left_col_name] + 1
self.class.base_class.transaction {
self.class.base_class.delete_all( "#{scope_condition} and #{left_col_name} > #{self[left_col_name]} and #{right_col_name} < #{self[right_col_name]}" )
self.class.base_class.update_all( "#{left_col_name} = (#{left_col_name} - #{dif})", "#{scope_condition} AND #{left_col_name} >= #{self[right_col_name]}" )
self.class.base_class.update_all( "#{right_col_name} = (#{right_col_name} - #{dif} )", "#{scope_condition} AND #{right_col_name} >= #{self[right_col_name]}" )
}
end