aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-05 16:27:39 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-05 16:56:50 -0700
commita79e1de90a6062926a8ec11870702923eb691944 (patch)
tree1b4fcddd64ba99b460d32784b169f5643abb16a4 /activerecord
parentb1667c7c2c1aba4a2adb5f36ad9499c01763655d (diff)
downloadrails-a79e1de90a6062926a8ec11870702923eb691944.tar.gz
rails-a79e1de90a6062926a8ec11870702923eb691944.tar.bz2
rails-a79e1de90a6062926a8ec11870702923eb691944.zip
reduce method calls to the join base object
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index dc466eafc2..3d754af5b3 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1874,12 +1874,14 @@ module ActiveRecord
end
def instantiate(rows)
- rows.each_with_index do |row, i|
- primary_id = join_base.record_id(row)
+ primary_key = join_base.aliased_primary_key
+
+ rows.each_with_index do |model, i|
+ primary_id = model[primary_key]
unless @base_records_hash[primary_id]
- @base_records_in_order << (@base_records_hash[primary_id] = join_base.instantiate(row))
+ @base_records_in_order << (@base_records_hash[primary_id] = join_base.instantiate(model))
end
- construct(@base_records_hash[primary_id], @associations, join_associations.dup, row)
+ construct(@base_records_hash[primary_id], @associations, join_associations.dup, model)
end
remove_duplicate_results!(join_base.active_record, @base_records_in_order, @associations)
return @base_records_in_order