Adds an example for using ArraySerializer under Render independently.

This commit is contained in:
Matjaz Muhic 2014-03-06 19:53:24 +01:00
parent 97f7914107
commit d9ff6db36d

View File

@ -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: