aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/association_preload.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-01-31 07:50:15 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2008-01-31 07:50:15 +0000
commitbe827f9348a703b3048cb7728d0de6d019279bd9 (patch)
tree951f051662b7c26754fa31ea05dce255523014ee /activerecord/lib/active_record/association_preload.rb
parente59978aa867ef07e16ad64f73f1ed5cafa98d0ea (diff)
downloadrails-be827f9348a703b3048cb7728d0de6d019279bd9.tar.gz
rails-be827f9348a703b3048cb7728d0de6d019279bd9.tar.bz2
rails-be827f9348a703b3048cb7728d0de6d019279bd9.zip
Fixed preloading belongs_to associations which reference a custom foreign key. References #9640.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8762 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/association_preload.rb')
-rw-r--r--activerecord/lib/active_record/association_preload.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb
index 6fa49dfbe8..87b087bfea 100644
--- a/activerecord/lib/active_record/association_preload.rb
+++ b/activerecord/lib/active_record/association_preload.rb
@@ -180,6 +180,7 @@ module ActiveRecord
klass = klass_name.constantize
table_name = klass.table_name
+ primary_key = klass.primary_key
conditions = "#{table_name}.#{primary_key} IN (?)"
conditions << append_conditions(options, preload_options)
associated_records = klass.find(:all, :conditions => [conditions, id_map.keys.uniq],
@@ -187,7 +188,7 @@ module ActiveRecord
:select => options[:select],
:joins => options[:joins],
:order => options[:order])
- set_association_single_records(id_map, reflection.name, associated_records, 'id')
+ set_association_single_records(id_map, reflection.name, associated_records, primary_key)
end
end