I'm trying to implement the JSON API for my Rails app. It requires attributes field to be defined. But ActiveModel::Serializer
has a method with the same name, hence
class FooSerializer < ActiveModel::Serializer
attributes :attributes
def attributes
{
# to be filled
}
end
end
will just override the original method. Is that ever possible to add the attributes field somehow?
ActiveModel Serializer has support for JSON API out of the box. You just need to setup the proper adapter.
ActiveModelSerializers.config.adapter = :json_api
https://github.com/rails-api/active_model_serializers/blob/v0.10.6/docs/general/adapters.md