From 7865bae693666e6b414f1edabd9fa4b3a7d917c6 Mon Sep 17 00:00:00 2001 From: Chris Chiu Date: Sat, 4 Feb 2017 22:38:47 -0800 Subject: [PATCH] Adding scoping to dependent relationships --- lib/acts_as_paranoid/core.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/acts_as_paranoid/core.rb b/lib/acts_as_paranoid/core.rb index 2855d5b..1f3a878 100644 --- a/lib/acts_as_paranoid/core.rb +++ b/lib/acts_as_paranoid/core.rb @@ -205,7 +205,7 @@ def destroy_paranoid_associations self.class.dependent_associations.each do |reflection| if reflection.klass.paranoid? dependent_type = reflection.options[:dependent] - association_scope = association(reflection.name).association_scope + association_scope = association(reflection.name).association_scope.where(self.class.paranoid_column => nil) if dependent_type == :destroy association_scope.each do |object| object.send(reflection.options[:dependent])