diff options
author | Subba Rao Pasupuleti <subbarao.pasupuleti@gmail.com> | 2010-07-10 12:29:09 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-21 14:25:19 +0200 |
commit | c0bfa0bfc17f4aa615cd9d1006509e0d84b5692d (patch) | |
tree | c5515ed322b1f880c86402ce7aee227c0e6be60e /activerecord/lib/active_record | |
parent | 6ba7d5e6544d636a763a40d1543f96d0e0bd77d5 (diff) | |
download | rails-c0bfa0bfc17f4aa615cd9d1006509e0d84b5692d.tar.gz rails-c0bfa0bfc17f4aa615cd9d1006509e0d84b5692d.tar.bz2 rails-c0bfa0bfc17f4aa615cd9d1006509e0d84b5692d.zip |
In nested_attributes when association is not loaded and association
record is saved and then in memory record attributes should be saved
[#5053 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/associations/association_collection.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 7abb738a74..7100be0245 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -477,7 +477,14 @@ module ActiveRecord callback(:before_add, record) yield(record) if block_given? @target ||= [] unless loaded? - @target << record unless @reflection.options[:uniq] && @target.include?(record) + index = @target.index(record) + unless @reflection.options[:uniq] && index + if index + @target[index] = record + else + @target << record + end + end callback(:after_add, record) set_inverse_instance(record, @owner) record |