mirror of
https://github.com/samsonjs/grape-active_model_serializers.git
synced 2026-04-27 14:57:43 +00:00
Updated readme as to new root behaviour
This commit is contained in:
parent
639daa9e4f
commit
e138ea4276
1 changed files with 18 additions and 0 deletions
18
README.md
18
README.md
|
|
@ -55,6 +55,24 @@ end
|
||||||
```
|
```
|
||||||
In this case, as User objects are being returned, grape-active_model_serializers will look for a serializer named UserSerializer.
|
In this case, as User objects are being returned, grape-active_model_serializers will look for a serializer named UserSerializer.
|
||||||
|
|
||||||
|
### Array roots
|
||||||
|
When serializing an array, the array root is set to the innermost namespace name if there is one, otherwise it is set to the route name (e.g. get 'name')
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
namespace :users do
|
||||||
|
get ":id" do
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# root = users
|
||||||
|
```
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
get "people" do
|
||||||
|
@user = User.all
|
||||||
|
end
|
||||||
|
# root = people
|
||||||
|
```
|
||||||
|
|
||||||
### Manually specifying serializer options
|
### Manually specifying serializer options
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue