This commit is contained in:
twinturbo
2012-07-14 13:12:26 +02:00
parent b91e63c4ec
commit 2b9cd97436
2 changed files with 46 additions and 2 deletions

View File

@@ -257,7 +257,7 @@ module ActiveModel
end
def attribute(attr, options={})
self._attributes = _attributes.merge(attr => options[:key] || attr)
self._attributes = _attributes.merge(attr => options[:key] || attr.to_s.gsub(/\?$/, '').to_sym)
unless method_defined?(attr)
class_eval "def #{attr}() object.read_attribute_for_serialization(:#{attr}) end", __FILE__, __LINE__
@@ -522,4 +522,4 @@ module ActiveModel
ActiveSupport::Notifications.instrument("#{name}.serializer", payload, &block)
end
end
end
end