aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2016-07-04 13:32:53 -0300
committerGitHub <noreply@github.com>2016-07-04 13:32:53 -0300
commit9552f8b457a674c66f99d6cbef244fbb7de6ba34 (patch)
tree69aa8d72f165696eec31840fe11fa55f92802a0c
parente8f167d2f80032203502d96271bcf09e1af9e18a (diff)
parent77d91d1d2be24b54128a5f8b150a78ec20523487 (diff)
downloadrails-9552f8b457a674c66f99d6cbef244fbb7de6ba34.tar.gz
rails-9552f8b457a674c66f99d6cbef244fbb7de6ba34.tar.bz2
rails-9552f8b457a674c66f99d6cbef244fbb7de6ba34.zip
Merge pull request #25680 from HermanHiddema/fix/unnecessary-nesting-in-handle-dependency
Fixed unnecessary nesting in handle_dependency
-rw-r--r--activerecord/lib/active_record/associations/has_many_association.rb12
1 files changed, 5 insertions, 7 deletions
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