diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2017-07-25 15:41:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-25 15:41:14 -0400 |
commit | eb080d91ce83bad4d0c20d3f1b68e3daa72b04e5 (patch) | |
tree | de2c204d98ac35269b811ccb8c9fb7475863d7e9 | |
parent | 9cbd8890069b0b6f832eb87a38bbcaaad31ca03b (diff) | |
parent | 21c0e0e89176b832a286bc6381b6ca2a9a56f1de (diff) | |
download | rails-eb080d91ce83bad4d0c20d3f1b68e3daa72b04e5.tar.gz rails-eb080d91ce83bad4d0c20d3f1b68e3daa72b04e5.tar.bz2 rails-eb080d91ce83bad4d0c20d3f1b68e3daa72b04e5.zip |
Merge pull request #29941 from kamipo/remove_single_element_array_preprocess
Remove single element array preprocess
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/association.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index 1985b38f8a..5ba03c555a 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -105,7 +105,7 @@ module ActiveRecord end 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 def scope diff --git a/activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb b/activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb index 1bc066363c..b87b5c36dd 100644 --- a/activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +++ b/activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb @@ -12,7 +12,7 @@ module ActiveRecord type_to_ids_mapping.map do |type, ids| { 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 |