aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-09-21 02:40:26 -0700
committerJon Leighton <j@jonathanleighton.com>2012-09-21 02:40:26 -0700
commit834d6da54e459f6354fe7b349779d690652cc7a8 (patch)
tree690685d9871c69e74ba4669ac57cd0060bc2fc11 /activerecord/lib/active_record
parenta507c641ec78ab8781b18c42a75ccad75362af8e (diff)
parent217a8b01b1349d50fc9c331e9411034289c640ab (diff)
downloadrails-834d6da54e459f6354fe7b349779d690652cc7a8.tar.gz
rails-834d6da54e459f6354fe7b349779d690652cc7a8.tar.bz2
rails-834d6da54e459f6354fe7b349779d690652cc7a8.zip
Merge pull request #5248 from jcoleman/should-unset-association-when-an-existing-record-is-destroyed
Unset association when existing record is destroyed.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/autosave_association.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index 290f57659d..a30f888a7a 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -394,6 +394,7 @@ module ActiveRecord
autosave = reflection.options[:autosave]
if autosave && record.marked_for_destruction?
+ self[reflection.foreign_key] = nil
record.destroy
elsif autosave != false
saved = record.save(:validate => !autosave) if record.new_record? || (autosave && record.changed_for_autosave?)