Skip to content
Browse files

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
  • Loading branch information...
1 parent c398e83 commit 0d34c28199839882076e95a20bcae0be44345a1c @jamis jamis committed Jan 11, 2007
Showing with 1 addition and 0 deletions.
  1. +1 −0 activerecord/lib/active_record/associations/has_one_association.rb
View
1 activerecord/lib/active_record/associations/has_one_association.rb
@@ -24,6 +24,7 @@ def create(attrs = {}, replace_existing = true)
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

0 comments on commit 0d34c28

Please sign in to comment.
Something went wrong with that request. Please try again.