add feature to include pagination links in response

This commit is contained in:
Bruno Bacarini
2015-08-02 18:02:56 -03:00
parent e384b65f5d
commit f7c77c1256
6 changed files with 98 additions and 4 deletions

View File

@@ -273,6 +273,18 @@ 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
If you want pagination links in your response, specify it in the `render`
```ruby
render json: @posts, pagination: true
```
AMS relies on either Kaminari or WillPaginate. Please install either dependency by adding one of those to your Gemfile.
Pagination links will only be included in your response if you are using an Adapter that supports `root`, as JsonAPI and Json adapters, the default adapter (FlattenJson) doesn't have `root`.
## Caching
To cache a serializer, call ```cache``` and pass its options.