You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[#2104](https://github.com/rails-api/active_model_serializers/pull/2104) Documentation for serializers and rendering. (@cassidycodes)
28
+
-[#2081](https://github.com/rails-api/active_model_serializers/pull/2081) Documentation for `include` option in adapters. (@charlie-wasp)
29
+
-[#2120](https://github.com/rails-api/active_model_serializers/pull/2120) Documentation for association options: foreign_key, type, class_name, namespace. (@bf4)
-[#1878](https://github.com/rails-api/active_model_serializers/pull/1878) Cache key generation for serializers now uses `ActiveSupport::Cache.expand_cache_key` instead of `Array#join` by default and is also overridable. This change should be backward-compatible. (@markiz)
83
97
84
-
-[#1799](https://github.com/rails-api/active_model_serializers/pull/1799) Add documentation for setting the adapter. (@ScottKbka)
98
+
-[#1799](https://github.com/rails-api/active_model_serializers/pull/1799) Add documentation for setting the adapter. (@cassidycodes)
85
99
-[#1909](https://github.com/rails-api/active_model_serializers/pull/1909) Add documentation for relationship links. (@vasilakisfil, @NullVoxPopuli)
86
100
-[#1959](https://github.com/rails-api/active_model_serializers/pull/1959) Add documentation for root. (@shunsuke227ono)
87
101
-[#1967](https://github.com/rails-api/active_model_serializers/pull/1967) Improve type method documentation. (@yukideluxe)
Copy file name to clipboardExpand all lines: docs/general/adapters.md
+25-9Lines changed: 25 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,18 +141,25 @@ This adapter follows **version 1.0** of the [format specified](../jsonapi/schema
141
141
}
142
142
```
143
143
144
-
#### Included
144
+
###Include option
145
145
146
-
It will include the associated resources in the `"included"` member
147
-
when the resource names are included in the `include` option.
148
-
Including nested associated resources is also supported.
146
+
Which [serializer associations](https://github.com/rails-api/active_model_serializers/blob/master/docs/general/serializers.md#associations) are rendered can be specified using the `include` option. The option usage is consistent with [the include option in the JSON API spec](http://jsonapi.org/format/#fetching-includes), and is available in all adapters.
Copy file name to clipboardExpand all lines: docs/general/serializers.md
+21-2Lines changed: 21 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,10 @@ Where:
64
64
-`unless:`
65
65
-`virtual_value:`
66
66
-`polymorphic:` defines if polymorphic relation type should be nested in serialized association.
67
+
-`type:` the resource type as used by JSON:API, especially on a `belongs_to` relationship.
68
+
-`class_name:` used to determine `type` when `type` not given
69
+
-`foreign_key:` used by JSON:API on a `belongs_to` relationship to avoid unnecessarily loading the association object.
70
+
-`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.
67
71
- optional: `&block` is a context that returns the association's attributes.
68
72
- prevents `association_name` method from being called.
69
73
- return value of block is used as the association value.
@@ -382,11 +386,26 @@ The serialized value for a given key. e.g. `read_attribute_for_serialization(:ti
382
386
383
387
#### #links
384
388
385
-
PR please :)
389
+
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.
390
+
391
+
```ruby
392
+
ActiveModelSerializers::SerializableResource.new(
393
+
@post,
394
+
adapter::json_api,
395
+
links: {
396
+
self: {
397
+
href:'http://example.com/posts',
398
+
meta: {
399
+
stuff:'value'
400
+
}
401
+
}
402
+
}
403
+
)
404
+
```
386
405
387
406
#### #json_key
388
407
389
-
PR please :)
408
+
Returns the key used by the adapter as the resource root. See [root](#root) for more information.
0 commit comments