aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2013-05-03 07:39:33 -0700
committerJon Leighton <j@jonathanleighton.com>2013-05-03 07:39:33 -0700
commitf1af9f83757278f5f852f9c747dd367f1a591833 (patch)
tree2799ffd79b545dc6e910fd8acb6d86529782ca5e /activerecord/CHANGELOG.md
parent6023a5049172e2222181881679b56c0e29034c96 (diff)
parent534030cf83b078b10c08ffb587cc56e86773ea8c (diff)
downloadrails-f1af9f83757278f5f852f9c747dd367f1a591833.tar.gz
rails-f1af9f83757278f5f852f9c747dd367f1a591833.tar.bz2
rails-f1af9f83757278f5f852f9c747dd367f1a591833.zip
Merge pull request #9426 from exviva/nested_attributes_reuse_existing_new_record
Do not overwrite manually built records during one-to-one nested attribute assignment
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r--activerecord/CHANGELOG.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index c5b94763ff..917f606d0e 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,24 @@
+* Do not overwrite manually built records during one-to-one nested attribute assignment
+
+ For one-to-one nested associations, if you build the new (in-memory)
+ child object yourself before assignment, then the NestedAttributes
+ module will not overwrite it, e.g.:
+
+ class Member < ActiveRecord::Base
+ has_one :avatar
+ accepts_nested_attributes_for :avatar
+
+ def avatar
+ super || build_avatar(width: 200)
+ end
+ end
+
+ member = Member.new
+ member.avatar_attributes = {icon: 'sad'}
+ member.avatar.width # => 200
+
+ *Olek Janiszewski*
+
* fixes bug introduced by #3329. Now, when autosaving associations,
deletions happen before inserts and saves. This prevents a 'duplicate
unique value' database error that would occur if a record being created had