Provides a helper method to add pagination information to JSON responses.
Add this line to your application's Gemfile:
gem 'kaminari_json'
And then execute:
$ bundle
Or install it yourself as:
$ gem install kaminari_json
Adds pagination information based on the Array or ActiveRecord::Relation passed in and returns a JSON object.
Example:
class SomeController < ApplicationController
def index
@things = Thing.all
respond_to do |format|
format.json do
render json: json_paginate(@things)
end
end
end
end
An ActiveModel::Serializer can be specified as well.
render json: json_paginate(things, each_serializer: StatementForListSerializer)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request ======= kaminari_json =============
Kaminari pagination info for json responses.