diff options
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods/read.rb')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/read.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb index faed703167..dcc3d79de9 100644 --- a/activerecord/lib/active_record/attribute_methods/read.rb +++ b/activerecord/lib/active_record/attribute_methods/read.rb @@ -67,7 +67,9 @@ module ActiveRecord @attributes_cache.fetch(attr_name.to_s) { |name| column = @columns_hash.fetch(name) { return @attributes.fetch(name) { - @attributes[self.class.primary_key] if name == 'id' + if name == 'id' && self.class.primary_key != name + read_attribute(self.class.primary_key) + end } } |