mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Adds an example for using ArraySerializer under Render independently.
This commit is contained in:
parent
97f7914107
commit
d9ff6db36d
@ -170,6 +170,15 @@ def current_user_as_json_helper
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can also render an array of objects using ArraySerializer.
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
def users_array_as_json_helper(users)
|
||||||
|
ActiveModel::ArraySerializer.new(users, each_serializer: UserSerializer).to_json
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Disabling the root element
|
## Disabling the root element
|
||||||
|
|
||||||
You have 4 options to disable the root element, each with a slightly different scope:
|
You have 4 options to disable the root element, each with a slightly different scope:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user