mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Merge pull request #1096 from beauby/fix-attribute
Fix definition of serializer attributes with multiple calls to `attri…
This commit is contained in:
commit
e0b74d8731
@ -70,7 +70,7 @@ module ActiveModel
|
|||||||
ActiveModelSerializers.silence_warnings do
|
ActiveModelSerializers.silence_warnings do
|
||||||
define_method key do
|
define_method key do
|
||||||
object.read_attribute_for_serialization(attr)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
3
test/fixtures/poro.rb
vendored
3
test/fixtures/poro.rb
vendored
@ -134,7 +134,8 @@ end
|
|||||||
|
|
||||||
AuthorSerializer = Class.new(ActiveModel::Serializer) do
|
AuthorSerializer = Class.new(ActiveModel::Serializer) do
|
||||||
cache key:'writer', skip_digest: true
|
cache key:'writer', skip_digest: true
|
||||||
attributes :id, :name
|
attribute :id
|
||||||
|
attribute :name
|
||||||
|
|
||||||
has_many :posts
|
has_many :posts
|
||||||
has_many :roles
|
has_many :roles
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user