mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Add pagination links automatically
Pagination links will be included in your response automatically as long as the resource is paginated using Kaminari or WillPaginate and if you are using a JSON-API adapter. The others adapters does not have this feature.
This commit is contained in:
@@ -118,7 +118,7 @@ If you wish to use a serializer other than the default, you can explicitly pass
|
||||
render json: @posts, each_serializer: PostPreviewSerializer
|
||||
|
||||
# Or, you can explicitly provide the collection serializer as well
|
||||
render json: @posts, serializer: PaginatedSerializer, each_serializer: PostPreviewSerializer
|
||||
render json: @posts, serializer: CollectionSerializer, each_serializer: PostPreviewSerializer
|
||||
```
|
||||
|
||||
### Meta
|
||||
@@ -272,6 +272,11 @@ And you can change the JSON key that the serializer should use for a particular
|
||||
|
||||
The `url` declaration describes which named routes to use while generating URLs
|
||||
for your JSON. Not every adapter will require URLs.
|
||||
## Pagination
|
||||
|
||||
Pagination links will be included in your response automatically as long as the resource is paginated using [Kaminari](https://github.com/amatsuda/kaminari) or [WillPaginate](https://github.com/mislav/will_paginate) and if you are using a ```JSON-API``` adapter. The others adapters does not have this feature.
|
||||
|
||||
For more information about it, please see in our docs [How to add pagination links](https://github.com/rails-api/active_model_serializers/blob/master/docs/howto/add_pagination_links.md)
|
||||
|
||||
## Caching
|
||||
|
||||
|
||||
Reference in New Issue
Block a user