aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 6020aa238f..e75ff6fd69 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -459,7 +459,11 @@ module ActiveRecord
end
if result.size == expected_size
- result
+ # 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] }
else
raise_record_not_found_exception!(ids, result.size, expected_size)
end