added documentation for adding custom root

This commit is contained in:
Kory Tegman 2016-01-06 15:57:49 -08:00
parent 7d4f0c5c8a
commit d153dfe2cd

View File

@ -113,8 +113,25 @@ PR please :)
#### root
PR please :)
By default the Json Adapter `root` will follow snake case format, like so:
| resource | single root | collection root |
|----------|-------------|-----------------|
| UserPost | user_posts | user_post |
If you would like to change the `root` of your json, specify it in the render call:
```ruby
render json: @user_post, root: "admin_post"
```
This will produce json like:
```json
{"admin_post": {
"title": "how to do open source"
}
}
```
#### serializer
PR please :)