aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-07-04 16:14:56 -0700
committerJon Leighton <j@jonathanleighton.com>2011-07-04 16:14:56 -0700
commit892c99ca5cfc8b9ea1a06066f23bec847838f7f8 (patch)
treed7a8eadb1e16f59798612512c2473e88455b99f0 /activerecord/lib
parent718542bb182af38d225384b26adb820c7589ea9a (diff)
parent7d3aa2462ce83abe5824c4abc1c326f0c52c1f03 (diff)
downloadrails-892c99ca5cfc8b9ea1a06066f23bec847838f7f8.tar.gz
rails-892c99ca5cfc8b9ea1a06066f23bec847838f7f8.tar.bz2
rails-892c99ca5cfc8b9ea1a06066f23bec847838f7f8.zip
Merge pull request #1964 from kommen/has_one_fix
Only call set_owner_attributes for has_one association if target exists. [3.1.0rc4]
Diffstat (limited to 'activerecord/lib')
-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 6b8201973a..2131edbc20 100644
--- a/activerecord/lib/active_record/associations/has_one_association.rb
+++ b/activerecord/lib/active_record/associations/has_one_association.rb
@@ -19,7 +19,7 @@ module ActiveRecord
if owner.persisted? && save && !record.save
nullify_owner_attributes(record)
- set_owner_attributes(target)
+ set_owner_attributes(target) if target
raise RecordNotSaved, "Failed to save the new associated #{reflection.name}."
end
end