From 7d3aa2462ce83abe5824c4abc1c326f0c52c1f03 Mon Sep 17 00:00:00 2001 From: Dieter Komendera Date: Mon, 4 Jul 2011 18:39:25 +0200 Subject: Only call set_owner_attributes for has_one association if target exists. --- activerecord/lib/active_record/associations/has_one_association.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib') 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 -- cgit v1.2.3