diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-01-08 19:59:30 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-11 13:45:07 -0800 |
commit | 7f7b480098fa780dd76b4c1243230d74be67b3ca (patch) | |
tree | c94d3876cd75372e07c7b050e43508f85ded2183 /activerecord/lib/active_record/associations/has_one_association.rb | |
parent | 1bc71ed9607ba88c21c14b670a4308c8549f3941 (diff) | |
download | rails-7f7b480098fa780dd76b4c1243230d74be67b3ca.tar.gz rails-7f7b480098fa780dd76b4c1243230d74be67b3ca.tar.bz2 rails-7f7b480098fa780dd76b4c1243230d74be67b3ca.zip |
When assigning a has_one, if the new record fails to save, raise an error
Diffstat (limited to 'activerecord/lib/active_record/associations/has_one_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/has_one_association.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb index a4332a0511..693c80163a 100644 --- a/activerecord/lib/active_record/associations/has_one_association.rb +++ b/activerecord/lib/active_record/associations/has_one_association.rb @@ -32,9 +32,9 @@ module ActiveRecord loaded if @owner.persisted? && record && save - record.save && self - else - record && self + unless record.save + raise RecordNotSaved, "Failed to save the new associated #{@reflection.name}." + end end end |