def destroy_descendants
      return if right.nil? || left.nil? || skip_before_destroy

      if acts_as_nested_set_options[:dependent] == :destroy
        descendants.each do |model|
          model.skip_before_destroy = true
          model.destroy
        end
      else
        c = nested_set_scope.where(left_field_name.to_sym.gt => left, right_field_name.to_sym.lt => right)
        scope_class.where(c.selector).delete_all
      end

      # update lefts and rights for remaining nodes
      diff = right - left + 1

      scope_class.with(:safe => true).where(
        nested_set_scope.where(left_field_name.to_sym.gt => right).selector
      ).inc(left_field_name, -diff)

      scope_class.with(:safe => true).where(
        nested_set_scope.where(right_field_name.to_sym.gt => right).selector
      ).inc(right_field_name, -diff)

      # Don't allow multiple calls to destroy to corrupt the set
      self.skip_before_destroy = true
    end
def destroy_descendants
      return if right.nil? || left.nil? || skip_before_destroy

      if acts_as_nested_set_options[:dependent] == :destroy
        descendants.each do |model|
          model.skip_before_destroy = true
          model.destroy
        end
      else
        c = nested_set_scope.where(left_field_name.to_sym.gt => left, right_field_name.to_sym.lt => right)
        scope_class.where(c.selector).delete_all
      end

      # update lefts and rights for remaining nodes
      diff = right - left + 1

      scope_class.with(:safe => true).where(
        nested_set_scope.where(left_field_name.to_sym.gt => right).selector
      ).inc(left_field_name, -diff)

      scope_class.with(:safe => true).where(
        nested_set_scope.where(right_field_name.to_sym.gt => right).selector
      ).inc(right_field_name, -diff)

      # Don't allow multiple calls to destroy to corrupt the set
      self.skip_before_destroy = true
    end
Prunes a branch off of the tree, shifting all of the elements on the right
 back to the left so the counts still work