aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorMiguel Grazziotin <miguelgraz@gmail.com>2015-06-03 20:42:52 -0300
committerMiguel Grazziotin <miguelgraz@gmail.com>2015-06-03 20:42:52 -0300
commit24389135b2eac027f3079476e776587c5f74b350 (patch)
tree738d7a815f30586c0ff09cf1ffc6292fad4719ba /activerecord/lib/active_record
parentdcee87c9fc2f16e240a90c564a82d23e9f9e9181 (diff)
downloadrails-24389135b2eac027f3079476e776587c5f74b350.tar.gz
rails-24389135b2eac027f3079476e776587c5f74b350.tar.bz2
rails-24389135b2eac027f3079476e776587c5f74b350.zip
[#20338] improving implementation, fixing and adding some more specs
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb7
1 files changed, 2 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index e75ff6fd69..48a7d15ea8 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -459,11 +459,8 @@ module ActiveRecord
end
if result.size == expected_size
- # result
- records_by_id = result.each_with_object(Hash.new) do |record, by_id|
- by_id[record.id] = record
- end
- ids.first(expected_size).collect { |id| records_by_id[id] }
+ records_by_id = result.index_by(&:id)
+ ids.first(expected_size).collect { |id| records_by_id[id.to_i] }
else
raise_record_not_found_exception!(ids, result.size, expected_size)
end