Skip to content
Browse files

Fix #5549.

  • Loading branch information...
1 parent 4c44ca5 commit 1b9fd797b3a3183044a3d7b9965b535ee7e27bc6 @jonleighton jonleighton committed Mar 28, 2012
View
1 activerecord/lib/active_record/attribute_methods.rb
@@ -64,6 +64,7 @@ def define_attribute_methods
return if attribute_methods_generated?
superclass.define_attribute_methods unless self == base_class
super(column_names)
+ column_names.each { |name| define_external_attribute_method(name) }
@attribute_methods_generated = true
end
end
View
9 activerecord/lib/active_record/attribute_methods/read.rb
@@ -71,22 +71,25 @@ def define_method_attribute(attr_name)
generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1
def __temp__
- #{internal_attribute_access_code(attr_name, cast_code)}
+ #{internal_attribute_access_code(attr_name, attribute_cast_code(attr_name))}
end
alias_method '#{attr_name}', :__temp__
undef_method :__temp__
STR
+ end
+
+ private
+ def define_external_attribute_method(attr_name)
generated_external_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1
def __temp__(v, attributes, attributes_cache, attr_name)
- #{external_attribute_access_code(attr_name, cast_code)}
+ #{external_attribute_access_code(attr_name, attribute_cast_code(attr_name))}
end
alias_method '#{attr_name}', :__temp__
undef_method :__temp__
STR
end
- private
def cacheable_column?(column)
attribute_types_cached_by_default.include?(column.type)
end

0 comments on commit 1b9fd79

Please sign in to comment.
Something went wrong with that request. Please try again.