Open
Description
Expected behavior vs actual behavior
If attributes list has keyword, the serializer will be failed, the error is
Rendered ActiveModel::Serializer::CollectionSerializer with ActiveModelSerializers::Adapter::Attributes ArgumentError: wrong number of arguments (given 0, expected 1)
class ApiSerializer < ApplicationSerializer
attributes :id,
:group_name,
:name,
:endpoint,
:method,
:version,
:created_at,
:updated_at,
:description
#...
end
Solutions
class ApiSerializer < ApplicationSerializer
attributes :id,
:group_name,
:name,
:endpoint,
:version,
:created_at,
:updated_at,
:description
attribute :method
def method
object.method
end
end
I think active_model_serializers should tell the developer that attributes should not include keywords, otherwise, the developer will not know the error's detail information. If I have time, I will create PR, but I want the library creator could improve this issue.
Thanks a lot