Merge pull request #1096 from beauby/fix-attribute

Fix definition of serializer attributes with multiple calls to `attri…
This commit is contained in:
João Moura 2015-09-01 09:42:59 -03:00
commit e0b74d8731
2 changed files with 3 additions and 2 deletions

View File

@ -70,7 +70,7 @@ module ActiveModel
ActiveModelSerializers.silence_warnings do
define_method key do
object.read_attribute_for_serialization(attr)
end unless respond_to?(key, false) || _fragmented.respond_to?(attr)
end unless (key != :id && method_defined?(key)) || _fragmented.respond_to?(attr)
end
end

View File

@ -134,7 +134,8 @@ end
AuthorSerializer = Class.new(ActiveModel::Serializer) do
cache key:'writer', skip_digest: true
attributes :id, :name
attribute :id
attribute :name
has_many :posts
has_many :roles