From 585df5ad5cca0bfe962046c38b68d5ec53b99c9b 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 57bdf16e..2ab0afbc 100644 --- a/lib/paranoia.rb +++ b/lib/paranoia.rb @@ -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|