diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb index b77076983e89bac68da619d63d9c06fc416c3b5d..660fa9a564615620706400eba1f25bab2a0ad130 100644 --- a/activerecord/lib/active_record/attribute_methods/read.rb +++ b/activerecord/lib/active_record/attribute_methods/read.rb @@ -55,7 +55,7 @@ def cacheable_column?(column) # Define read method for serialized attribute. def define_read_method_for_serialized_attribute(attr_name) access_code = "@attributes_cache['#{attr_name}'] ||= unserialize_attribute('#{attr_name}')" - generated_attribute_methods.module_eval("def #{attr_name}; #{access_code}; end", __FILE__, __LINE__) + generated_attribute_methods.module_eval("def _#{attr_name}; #{access_code}; end; alias #{attr_name} _#{attr_name}", __FILE__, __LINE__) end # Define an attribute reader method. Cope with nil column.