mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Add documentation for root (#1959)
This commit is contained in:
parent
cb20b957ed
commit
ce8dd36633
@ -34,6 +34,7 @@ Misc:
|
||||
|
||||
- [#1799](https://github.com/rails-api/active_model_serializers/pull/1799) Add documentation for setting the adapter. (@ScottKbka)
|
||||
- [#1909](https://github.com/rails-api/active_model_serializers/pull/1909) Add documentation for relationship links. (@vasilakisfil, @NullVoxPopuli)
|
||||
- [#1959](https://github.com/rails-api/active_model_serializers/pull/1959) Add documentation for root. (@shunsuke227ono)
|
||||
|
||||
### [v0.10.2 (2016-07-05)](https://github.com/rails-api/active_model_serializers/compare/v0.10.1...v0.10.2)
|
||||
|
||||
|
||||
@ -217,7 +217,17 @@ The object being serialized.
|
||||
|
||||
#### #root
|
||||
|
||||
PR please :)
|
||||
Resource root which is included in `JSON` adapter. As you can see at [Adapters Document](adapters.md), `Attribute` adapter (default) and `JSON API` adapter does not include root at top level.
|
||||
By default, the resource root comes from the `model_name` of the serialized object's class.
|
||||
|
||||
There are several ways to specify root:
|
||||
* [Overriding the root key](rendering.md#overriding-the-root-key)
|
||||
* [Setting `type`](serializers.md#type)
|
||||
* Specifying the `root` option, e.g. `root: 'specific_name'`, during the serializer's initialization:
|
||||
|
||||
```ruby
|
||||
ActiveModelSerializers::SerializableResource.new(foo, root: 'bar')
|
||||
```
|
||||
|
||||
#### #scope
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user