Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/closure_tree/hierarchy_maintenance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _ct_before_destroy
_ct.with_advisory_lock do
delete_hierarchy_references
if _ct.options[:dependent] == :nullify
self.class.find(self.id).children.each { |c| c.rebuild! }
self.class.find(self.id).children.find_each { |c| c.rebuild! }
end
end
true # don't prevent destruction
Expand All @@ -79,7 +79,7 @@ def rebuild!(called_by_rebuild = false)
_ct_reorder_siblings if !called_by_rebuild
end

children.each { |c| c.rebuild!(true) }
children.find_each { |c| c.rebuild!(true) }

_ct_reorder_children if _ct.order_is_numeric? && children.present?
end
Expand Down Expand Up @@ -110,7 +110,7 @@ module ClassMethods
def rebuild!
_ct.with_advisory_lock do
hierarchy_class.delete_all # not destroy_all -- we just want a simple truncate.
roots.each { |n| n.send(:rebuild!) } # roots just uses the parent_id column, so this is safe.
roots.find_each { |n| n.send(:rebuild!) } # roots just uses the parent_id column, so this is safe.
end
nil
end
Expand Down