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:
parent
130064d504
commit
7dd7d76b86
1 changed files with 2 additions and 3 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue