Skip to content

Commit

Permalink
.really_destroy! should not destroy has_many :through records
Browse files Browse the repository at this point in the history
  • Loading branch information
atd authored and mathieujobin committed Mar 23, 2022
1 parent cc19cef commit 585df5a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/paranoia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ def really_destroy!
run_callbacks(:real_destroy) do
@_disable_counter_cache = paranoia_destroyed?
dependent_reflections = self.class.reflections.select do |name, reflection|
reflection.options[:dependent] == :destroy
reflection.options[:dependent] == :destroy &&
reflection.options[:through].blank?
end
if dependent_reflections.any?
dependent_reflections.each do |name, reflection|
Expand Down

0 comments on commit 585df5a

Please sign in to comment.