aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-03-30 11:09:27 +0100
committerJon Leighton <j@jonathanleighton.com>2012-03-30 11:09:27 +0100
commit7dd7d76b86b2168b39fb7f0c359d84ea6df0ce41 (patch)
tree3b01d2d355ffcf09909693f1553d8fe080b01200 /activerecord/lib/active_record
parent130064d5049cb6df4d0c14964c253d3bad26e001 (diff)
downloadrails-7dd7d76b86b2168b39fb7f0c359d84ea6df0ce41.tar.gz
rails-7dd7d76b86b2168b39fb7f0c359d84ea6df0ce41.tar.bz2
rails-7dd7d76b86b2168b39fb7f0c359d84ea6df0ce41.zip
recurse in read_attribute we get caching / don't duplicate code
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/attribute_methods/read.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb
index d108de385f..dcc3d79de9 100644
--- a/activerecord/lib/active_record/attribute_methods/read.rb
+++ b/activerecord/lib/active_record/attribute_methods/read.rb
@@ -67,9 +67,8 @@ module ActiveRecord
@attributes_cache.fetch(attr_name.to_s) { |name|
column = @columns_hash.fetch(name) {
return @attributes.fetch(name) {
- if name == 'id'
- primary_key = self.class.primary_key
- @columns_hash[primary_key].type_cast(@attributes[primary_key])
+ if name == 'id' && self.class.primary_key != name
+ read_attribute(self.class.primary_key)
end
}
}