diff options
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 1254d68e9a..bd77aa30c1 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -359,11 +359,7 @@ module ActiveRecord reset end - if @target.any? - @target = merge_target_lists(targets, @target) - else - @target = targets - end + @target = merge_target_lists(targets, @target) end end @@ -441,6 +437,9 @@ module ActiveRecord private def merge_target_lists(loaded, existing) + return loaded if existing.empty? + return existing if loaded.empty? + loaded.map do |f| i = existing.index(f) if i |