Adapter Specific
JSONAPI
::type
The ::type
method defines the JSONAPI type that will be rendered for this serializer. It either takes a String
or Symbol
as parameter.
Note: This method is useful only when using the :json_api
adapter.
Examples:
class UserProfileSerializer < ActiveModel::Serializer
type 'profile'
end
class AuthorProfileSerializer < ActiveModel::Serializer
type :profile
end
With the :json_api
adapter, the previous serializers would be rendered as:
{
"data": {
"id": "1",
"type": "profile"
}
}
::link
link :self do
href "https://example.com/link_author/#{object.id}"
end
link :author { link_author_url(object) }
link :link_authors { link_authors_url }
link :other, 'https://example.com/resource'
link :posts { link_author_posts_url(object) }
JSON
#root
PR please :)
#links
PR please :)
#json_key
PR please :)