# File lib/ancestry/instance_methods.rb, line 12
    def update_descendants_with_new_ancestry
      # If enabled and node is existing and ancestry was updated and the new ancestry is sane ...
      if !ancestry_callbacks_disabled? && !new_record? && ancestry_changed? && sane_ancestry?
        # ... for each descendant ...
        unscoped_descendants.each do |descendant|
          # ... replace old ancestry with new ancestry
          descendant.without_ancestry_callbacks do
            descendant.update_attribute(
              self.ancestry_base_class.ancestry_column,
              descendant.read_attribute(descendant.class.ancestry_column).gsub(
                # child_ancestry_was
                /^#{self.child_ancestry}/,
                # future child_ancestry
                if ancestors? then "#{read_attribute self.class.ancestry_column }/#{id}" else id.to_s end
              )
            )
          end
        end
      end
    end