Permalink
Browse files

Merge pull request #13838 from vipulnsward/13197-fix-has-one-document…

…ation

Add docs about behaviour of replacing a has_one associate object.
  • Loading branch information...
2 parents 61bd71e + f93ce1b commit e09c4028b3ad2ce5a0a9dca3b7eb62f49310e63c @dmathieu dmathieu committed Jan 28, 2014
Showing with 2 additions and 1 deletion.
  1. +2 −1 activerecord/lib/active_record/associations.rb
@@ -1213,7 +1213,8 @@ def has_many(name, scope = nil, options = {}, &extension)
# Returns the associated object. +nil+ is returned if none is found.
# [association=(associate)]
# Assigns the associate object, extracts the primary key, sets it as the foreign key,
- # and saves the associate object.
+ # and saves the associate object. To avoid database inconsistencies, permanently deletes an existing
+ # associated object when assigning a new one, even if the new one isn't saved to database.
# [build_association(attributes = {})]
# Returns a new object of the associated type that has been instantiated
# with +attributes+ and linked to this object through a foreign key, but has not

0 comments on commit e09c402

Please sign in to comment.