diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/read.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb index 54949ce0e2..769aa36e79 100644 --- a/activerecord/lib/active_record/attribute_methods/read.rb +++ b/activerecord/lib/active_record/attribute_methods/read.rb @@ -76,17 +76,17 @@ module ActiveRecord end def internal_attribute_access_code(attr_name, cast_code) - access_code = "(v=@attributes['#{attr_name}']) && #{cast_code}" + access_code = "(v=@attributes[attr_name]) && #{cast_code}" unless attr_name == primary_key - access_code.insert(0, "missing_attribute('#{attr_name}', caller) unless @attributes.has_key?('#{attr_name}'); ") + access_code.insert(0, "missing_attribute(attr_name, caller) unless @attributes.has_key?(attr_name); ") end if cache_attribute?(attr_name) - access_code = "@attributes_cache['#{attr_name}'] ||= (#{access_code})" + access_code = "@attributes_cache[attr_name] ||= (#{access_code})" end - access_code + "attr_name = '#{attr_name}'; #{access_code}" end def external_attribute_access_code(attr_name, cast_code) |