diff options
author | James Le Cuirot <chewi@aura-online.co.uk> | 2010-06-09 12:33:40 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-06-09 18:17:52 +0530 |
commit | 0265c708b9696c3943518ad5f3dabdc22c5eba11 (patch) | |
tree | 7656b7510358e01f53626dd74f611ff652d29b81 /activerecord/lib | |
parent | 6898c167c3906b87dcf52cf6c088ae9f08f3ad22 (diff) | |
download | rails-0265c708b9696c3943518ad5f3dabdc22c5eba11.tar.gz rails-0265c708b9696c3943518ad5f3dabdc22c5eba11.tar.bz2 rails-0265c708b9696c3943518ad5f3dabdc22c5eba11.zip |
Don't overwrite unsaved updates when loading an association but preserve the order of the loaded records. [#4642 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index d9903243ce..5b68ca2edb 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -388,7 +388,7 @@ module ActiveRecord begin if !loaded? if @target.is_a?(Array) && @target.any? - @target = find_target + @target.find_all {|t| t.new_record? } + @target = find_target.map { |f| i = @target.index(f); i ? @target.delete_at(i) : f } + @target else @target = find_target end |