Serializer Options serializer_opts
Serializer Options are passed to new Serializers
include
PR please :)
root
(JSON Adapter)
Overriding the resource root only applies when using the JSON adapter.
Normally, the resource root is derived from the class name of the resource being serialized.
e.g. UserPostSerializer.new(UserPost.new)
will be serialized with the root user_post
or user_posts
according the adapter collection pluralization rules.
When using the JSON adapter in your initializer (ActiveModelSerializers.config.adapter
= :json
), or passing in the adapter in your render call, you can
specify the root by passing it as an argument to render
. For example:
render json: @user_post, root: "admin_post", adapter: :json
This will be rendered as:
{
"admin_post": {
"title": "how to do open source"
}
}
Note: the Attributes
adapter (default) does not include a resource root. You also will not be able to create a single top-level root if you are using the :json_api adapter.
serializer
PR please :)
scope
PR please :)
scope_name
PR please :)