Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

calculate to_s on the primary key once

  • Loading branch information...
commit 09f37367f85b2b71934971c5a7db96df90233f63 1 parent 2deaa25
@tenderlove tenderlove authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 activerecord/lib/active_record/association_preload.rb
View
4 activerecord/lib/active_record/association_preload.rb
@@ -340,8 +340,8 @@ def preload_belongs_to_association(records, reflection, preload_options={})
klass = klass_name.constantize
table_name = klass.quoted_table_name
- primary_key = reflection.options[:primary_key] || klass.primary_key
- column_type = klass.columns.detect{|c| c.name == primary_key.to_s}.class
+ primary_key = (reflection.options[:primary_key] || klass.primary_key).to_s
+ column_type = klass.columns.detect{|c| c.name == primary_key}.type
ids = id_map.keys.map do |id|
if column_type == :integer
id.to_i

1 comment on commit 09f3736

@nijikon

Can this be pushed to 2-3-stable as well?

Please sign in to comment.
Something went wrong with that request. Please try again.