mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
Update README.md
I'm a bit embarrassed to admit that it took me a while to figure out this was a possibility, so I figured maybe this change will save some other poor chaps their time and/or pride.
This commit is contained in:
parent
8b7e9d32d7
commit
5504293776
12
README.md
12
README.md
@ -195,6 +195,18 @@ def default_serializer_options
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Disabling root globally
|
||||||
|
|
||||||
|
If you want to disable the ```root```-node for all serializers, not just when
|
||||||
|
they are used in ```respond_with```, you can set the ```root``` option for the
|
||||||
|
main class in an initializer just like with Arrays:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
ActiveSupport.on_load(:active_model_serializers) do
|
||||||
|
ActiveModel::Serializer.root = false
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
## Getting the old version
|
## Getting the old version
|
||||||
|
|
||||||
If you find that your project is already relying on the old rails to_json
|
If you find that your project is already relying on the old rails to_json
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user