Skip to content

Commit aeefb6a

Browse files
committed
revised docs to reflect the feedback
1 parent d153dfe commit aeefb6a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

docs/general/rendering.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,24 @@ PR please :)
113113

114114
#### root
115115

116-
By default the Json Adapter `root` will follow snake case format, like so:
116+
The resource root is derived from the class name of the resource being serialized.
117+
e.g. `UserPostSerializer.new(UserPost.new)` will be serialized with the root `user_post` or `user_posts` according the adapter collection pluralization rules.
117118

118-
| resource | single root | collection root |
119-
|----------|-------------|-----------------|
120-
| UserPost | user_posts | user_post |
121-
122-
If you would like to change the `root` of your json, specify it in the render call:
119+
Specify the root by passing it as an argument to `render`. For example:
123120

124121
```ruby
125-
render json: @user_post, root: "admin_post"
122+
render json: @user_post, root: "admin_post", adapter: :json
126123
```
127124

128-
This will produce json like:
125+
This will produce serialize as:
129126
```json
130127
{"admin_post": {
131128
"title": "how to do open source"
132129
}
133130
}
134131
```
132+
`Note: the Attributes adapter (default) does not include a resource root.`
133+
135134
#### serializer
136135

137136
PR please :)

0 commit comments

Comments
 (0)