aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-08-24 06:47:43 -0600
committerSean Griffin <sean@seantheprogrammer.com>2015-08-24 06:47:43 -0600
commit2170950b2f03383da69b275eb0710b78a4a2249a (patch)
tree08ff0373a42e3d300db7cb3093713dcb4bc8096c /activerecord/lib/active_record
parent5500e28eb3bb56663bc6e347d4a07a2b54f7b17f (diff)
parent19b168e611fb8fb547981c4535130c29856efd3a (diff)
downloadrails-2170950b2f03383da69b275eb0710b78a4a2249a.tar.gz
rails-2170950b2f03383da69b275eb0710b78a4a2249a.tar.bz2
rails-2170950b2f03383da69b275eb0710b78a4a2249a.zip
Merge pull request #21350 from agis-/issue-21223
Only nullify persisted has_one target associations
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/has_one_association.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb
index 5a92bc5e8a..1829453d73 100644
--- a/activerecord/lib/active_record/associations/has_one_association.rb
+++ b/activerecord/lib/active_record/associations/has_one_association.rb
@@ -65,7 +65,7 @@ module ActiveRecord
when :destroy
target.destroy
when :nullify
- target.update_columns(reflection.foreign_key => nil)
+ target.update_columns(reflection.foreign_key => nil) if target.persisted?
end
end
end