def update_descendants_with_new_ancestry
unless ancestry_callbacks_disabled?
if changed.include?(self.base_class.ancestry_column.to_s) && !new_record? && valid?
descendants.each do |descendant|
descendant.without_ancestry_callbacks do
descendant.update_attribute(
self.base_class.ancestry_column,
descendant.read_attribute(descendant.class.ancestry_column).gsub(
/^#{self.child_ancestry}/,
if read_attribute(self.class.ancestry_column).blank? then id.to_s else "#{read_attribute self.class.ancestry_column }/#{id}" end
)
)
end
end
end
end
end