From 77d91d1d2be24b54128a5f8b150a78ec20523487 Mon Sep 17 00:00:00 2001 From: Herman Hiddema Date: Mon, 4 Jul 2016 14:13:02 +0200 Subject: Fixed unnecessary nesting in handle_dependency This nested if checked the same value as the containing case statement. Moved the code in the if/else into when/else in the containing case. --- .../lib/active_record/associations/has_many_association.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index a9f6aaafef..4daafedcfb 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -27,14 +27,12 @@ module ActiveRecord throw(:abort) end + when :destroy + # No point in executing the counter update since we're going to destroy the parent anyway + load_target.each { |t| t.destroyed_by_association = reflection } + destroy_all else - if options[:dependent] == :destroy - # No point in executing the counter update since we're going to destroy the parent anyway - load_target.each { |t| t.destroyed_by_association = reflection } - destroy_all - else - delete_all - end + delete_all end end -- cgit v1.2.3