aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorHerman Hiddema <herman@hiddema.nl>2016-07-04 14:13:02 +0200
committerHerman Hiddema <herman@hiddema.nl>2016-07-04 14:13:02 +0200
commit77d91d1d2be24b54128a5f8b150a78ec20523487 (patch)
tree193b6c10d997b49bd3b51e5844d52efc1983bb47 /activerecord/lib
parent9bdf08c5a57d0411db866124eca4deba5097c30a (diff)
downloadrails-77d91d1d2be24b54128a5f8b150a78ec20523487.tar.gz
rails-77d91d1d2be24b54128a5f8b150a78ec20523487.tar.bz2
rails-77d91d1d2be24b54128a5f8b150a78ec20523487.zip
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.
Diffstat (limited to 'activerecord/lib')
-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