Skip to content

Commit

Permalink
Delete nodes from leafs up to root
Browse files Browse the repository at this point in the history
When destroying dependents, start with the furthest down leafs and work
your way up to the current node

#90
  • Loading branch information
kbrock committed Mar 20, 2023
1 parent 6f3326e commit d00654a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ancestry/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def apply_orphan_strategy_rootify
def apply_orphan_strategy_destroy
return if ancestry_callbacks_disabled? || new_record?

unscoped_descendants.each do |descendant|
unscoped_descendants.ordered_by_ancestry.reverse_order.each do |descendant|
descendant.without_ancestry_callbacks do
descendant.destroy
end
Expand Down

0 comments on commit d00654a

Please sign in to comment.