From d960e5e46c4dbe92d251ec70a3ede609c7f25212 Mon Sep 17 00:00:00 2001 From: Antonio Tapiador del Dujo Date: Fri, 8 Mar 2019 13:40:00 +0100 Subject: [PATCH] .really_destroy! should not destroy has_many :through records https://github.com/rubysherpas/paranoia/issues/466 --- lib/paranoia.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/paranoia.rb b/lib/paranoia.rb index 4ba4c389..288f04b4 100644 --- a/lib/paranoia.rb +++ b/lib/paranoia.rb @@ -141,7 +141,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|