docs/general/serializers.md in active_model_serializers-0.10.5 vs docs/general/serializers.md in active_model_serializers-0.10.6

- old
+ new

@@ -62,10 +62,14 @@ - `serializer:` - `if:` - `unless:` - `virtual_value:` - `polymorphic:` defines if polymorphic relation type should be nested in serialized association. + - `type:` the resource type as used by JSON:API, especially on a `belongs_to` relationship. + - `class_name:` used to determine `type` when `type` not given + - `foreign_key:` used by JSON:API on a `belongs_to` relationship to avoid unnecessarily loading the association object. + - `namespace:` used when looking up the serializer and `serializer` is not given. Falls back to the parent serializer's `:namespace` instance options, which, when present, comes from the render options. See [Rendering#namespace](rendering.md#namespace] for more details. - optional: `&block` is a context that returns the association's attributes. - prevents `association_name` method from being called. - return value of block is used as the association value. - yields the `serializer` to the block. - `include_data false` prevents the `data` key from being rendered in the JSON API relationship. @@ -380,14 +384,29 @@ The serialized value for a given key. e.g. `read_attribute_for_serialization(:title) #=> 'Hello World'` #### #links -PR please :) +Allows you to modify the `links` node. By default, this node will be populated with the attributes set using the [::link](#link) method. Using `links: nil` will remove the `links` node. +```ruby +ActiveModelSerializers::SerializableResource.new( + @post, + adapter: :json_api, + links: { + self: { + href: 'http://example.com/posts', + meta: { + stuff: 'value' + } + } + } +) +``` + #### #json_key -PR please :) +Returns the key used by the adapter as the resource root. See [root](#root) for more information. ## Examples Given two models, a `Post(title: string, body: text)` and a `Comment(name: string, body: text, post_id: integer)`, you will have two