Skip to content

Commit

Permalink
Don't call nil-method on object associations
Browse files Browse the repository at this point in the history
When a model has no :dependent option in their association, this is nil. `target.send(options[:dependent])` will fail in this case.
  • Loading branch information
Shigawire authored Jul 8, 2019
1 parent 0600183 commit 34318e5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/paranoia/active_record_5_2.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module HandleParanoiaDestroyedInBelongsToAssociation
def handle_dependency
return unless load_target
return unless options[:dependent]

case options[:dependent]
when :destroy
Expand All @@ -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
Expand Down

0 comments on commit 34318e5

Please sign in to comment.