1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #29941 from kamipo/remove_single_element_array_preprocess

Remove single element array preprocess
This commit is contained in:
Sean Griffin 2017-07-25 15:41:14 -04:00 committed by GitHub
commit eb080d91ce
2 changed files with 2 additions and 2 deletions

View file

@ -105,7 +105,7 @@ module ActiveRecord
end end
def records_for(ids, &block) def records_for(ids, &block)
scope.where(association_key_name => ids.size == 1 ? ids.first : ids).load(&block) scope.where(association_key_name => ids).load(&block)
end end
def scope def scope

View file

@ -12,7 +12,7 @@ module ActiveRecord
type_to_ids_mapping.map do |type, ids| type_to_ids_mapping.map do |type, ids|
{ {
associated_table.association_foreign_type.to_s => type, associated_table.association_foreign_type.to_s => type,
associated_table.association_foreign_key.to_s => ids.size > 1 ? ids : ids.first associated_table.association_foreign_key.to_s => ids
} }
end end
end end