mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Allow for the implicit use of ArraySerializer when :each_serializer is specified.
This commit is contained in:
@@ -107,7 +107,12 @@ If you wish to use a serializer other than the default, you can explicitly pass
|
||||
#### 2. For an array resource:
|
||||
|
||||
```ruby
|
||||
render json: @posts, serializer: PaginatedSerializer, each_serializer: PostPreviewSerializer
|
||||
# Use the default `ArraySerializer`, which will use `each_serializer` to
|
||||
# serialize each element
|
||||
render json: @posts, each_serializer: PostPreviewSerializer
|
||||
|
||||
# Or, you can explicitly provide the collection serializer as well
|
||||
render json: @posts, serializer: PaginatedSerializer, each_serializer: PostPreviewSerializer
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
Reference in New Issue
Block a user