aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2007-01-11 18:10:42 +0000
committerJamis Buck <jamis@37signals.com>2007-01-11 18:10:42 +0000
commit0d34c28199839882076e95a20bcae0be44345a1c (patch)
treee1344ae55658a06e1a2778cd35c8b778352fda27
parentc398e83893121d02d7f99636cafb3382a21347c2 (diff)
downloadrails-0d34c28199839882076e95a20bcae0be44345a1c.tar.gz
rails-0d34c28199839882076e95a20bcae0be44345a1c.tar.bz2
rails-0d34c28199839882076e95a20bcae0be44345a1c.zip
treat create! like create and make sure the target is loaded first
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5882 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activerecord/lib/active_record/associations/has_one_association.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb
index 8d24c43a1f..757895b6b4 100644
--- a/activerecord/lib/active_record/associations/has_one_association.rb
+++ b/activerecord/lib/active_record/associations/has_one_association.rb
@@ -24,6 +24,7 @@ module ActiveRecord
end
def create!(attrs = {}, replace_existing = true)
+ load_target if replace_existing
record = @reflection.klass.with_scope(:create => construct_scope[:create]) { @reflection.klass.create!(attrs) }
if replace_existing