diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-11-11 11:41:15 -0500 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-11-24 22:08:36 +0100 |
commit | 66212f69acc3d51af10ff76a18ff4c0bfa305ea5 (patch) | |
tree | 5cf9877fcecd1d88871eb55490e2bd7e7095f56b /activerecord/lib/active_record | |
parent | 18adbe9347727dc3eefe46395d52aafa347a0c73 (diff) | |
download | rails-66212f69acc3d51af10ff76a18ff4c0bfa305ea5.tar.gz rails-66212f69acc3d51af10ff76a18ff4c0bfa305ea5.tar.bz2 rails-66212f69acc3d51af10ff76a18ff4c0bfa305ea5.zip |
If a nested_attribute is being marked for destruction and at the same time an attr_accessor value is being assigned then the value being assigned is being ignored. This patch is a fix for that issue.
[#5939 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/nested_attributes.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb index 15f83a8579..050b521b6a 100644 --- a/activerecord/lib/active_record/nested_attributes.rb +++ b/activerecord/lib/active_record/nested_attributes.rb @@ -417,11 +417,8 @@ module ActiveRecord # Updates a record with the +attributes+ or marks it for destruction if # +allow_destroy+ is +true+ and has_destroy_flag? returns +true+. def assign_to_or_mark_for_destruction(record, attributes, allow_destroy) - if has_destroy_flag?(attributes) && allow_destroy - record.mark_for_destruction - else - record.attributes = attributes.except(*UNASSIGNABLE_KEYS) - end + record.attributes = attributes.except(*UNASSIGNABLE_KEYS) + record.mark_for_destruction if has_destroy_flag?(attributes) && allow_destroy end # Determines if a hash contains a truthy _destroy key. |