mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Merge pull request #166 from gabetax/initializer-documentation
Update documentation to use ActiveSupport.on_load to disable root
This commit is contained in:
commit
e79fe399a5
@ -132,7 +132,9 @@ more concise json. To disable the root element for arrays, you have 3 options:
|
|||||||
#### 1. Disable root globally for in `ArraySerializer`. In an initializer:
|
#### 1. Disable root globally for in `ArraySerializer`. In an initializer:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
ActiveModel::ArraySerializer.root = false
|
ActiveSupport.on_load(:active_model_serializers) do
|
||||||
|
self.root = false
|
||||||
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 2. Disable root per render call in your controller:
|
#### 2. Disable root per render call in your controller:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user