diff options
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 550b657102..2f7812d17b 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1563,7 +1563,16 @@ module ActiveRecord #:nodoc: self.class.read_methods << attr_name end - self.class.class_eval("def #{symbol}; #{access_code}; end") + begin + self.class.class_eval("def #{symbol}; #{access_code}; end") + rescue SyntaxError => err + self.class.read_methods.delete(attr_name) + if logger + logger.warn "Exception occured during reader method compilation." + logger.warn "Maybe #{attr_name} is not a valid Ruby identifier?" + logger.warn "#{err.message}" + end + end end # Returns true if the attribute is of a text column and marked for serialization. |