1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

recurse in read_attribute we get caching / don't duplicate code

This commit is contained in:
Jon Leighton 2012-03-30 11:09:27 +01:00
parent 130064d504
commit 7dd7d76b86

View file

@ -67,9 +67,8 @@ module ActiveRecord
@attributes_cache.fetch(attr_name.to_s) { |name| @attributes_cache.fetch(attr_name.to_s) { |name|
column = @columns_hash.fetch(name) { column = @columns_hash.fetch(name) {
return @attributes.fetch(name) { return @attributes.fetch(name) {
if name == 'id' if name == 'id' && self.class.primary_key != name
primary_key = self.class.primary_key read_attribute(self.class.primary_key)
@columns_hash[primary_key].type_cast(@attributes[primary_key])
end end
} }
} }