mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16: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
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
You have 4 options to disable the root element, each with a slightly different scope:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user