From 34318e5444e831f692948cba14c22baed39e7a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20K=C3=BCbler?= Date: Mon, 8 Jul 2019 12:30:30 +0200 Subject: [PATCH] Don't call nil-method on object associations When a model has no :dependent option in their association, this is nil. `target.send(options[:dependent])` will fail in this case. --- lib/paranoia/active_record_5_2.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/paranoia/active_record_5_2.rb b/lib/paranoia/active_record_5_2.rb index c9c5463f..5b644787 100644 --- a/lib/paranoia/active_record_5_2.rb +++ b/lib/paranoia/active_record_5_2.rb @@ -1,6 +1,7 @@ module HandleParanoiaDestroyedInBelongsToAssociation def handle_dependency return unless load_target + return unless options[:dependent] case options[:dependent] when :destroy @@ -18,6 +19,8 @@ def handle_dependency module HandleParanoiaDestroyedInHasOneAssociation def delete(method = options[:dependent]) + return unless options[:dependent] + if load_target case method when :delete