aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-11-01 19:04:30 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-11-01 19:04:30 -0200
commit1918b12c0429caec2a6134ac5e5b42ade103fe90 (patch)
tree7e9a61f8f5460d27231c295f843854a44961d2d9 /activerecord/lib
parentd9e70501a41d6a2e8dd4f0c4f7da78aaab6d2202 (diff)
downloadrails-1918b12c0429caec2a6134ac5e5b42ade103fe90.tar.gz
rails-1918b12c0429caec2a6134ac5e5b42ade103fe90.tar.bz2
rails-1918b12c0429caec2a6134ac5e5b42ade103fe90.zip
Fix wrong behavior where associations with dependent: :destroy options
was using nullify strategy This caused a regression in applications trying to upgrade. Also if the user set the dependent option as destroy he expects to get the records removed from the database.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 6b06a5f7fd..62f23f54f9 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -151,7 +151,7 @@ module ActiveRecord
# Removes all records from the association without calling callbacks
# on the associated records. It honors the `:dependent` option. However
- # if the `:dependent` value is `:destroy` then in that case the default
+ # if the `:dependent` value is `:destroy` then in that case the `:delete_all`
# deletion strategy for the association is applied.
#
# You can force a particular deletion strategy by passing a parameter.
@@ -170,9 +170,7 @@ module ActiveRecord
dependent = if dependent.present?
dependent
elsif options[:dependent] == :destroy
- # since delete_all should not invoke callbacks so use the default deletion strategy
- # for :destroy
- reflection.is_a?(ActiveRecord::Reflection::ThroughReflection) ? :delete_all : :nullify
+ :delete_all
else
options[:dependent]
end