Class: SimpleCrud::Pagination::WillPaginateAdapter
- Inherits:
-
Object
- Object
- SimpleCrud::Pagination::WillPaginateAdapter
- Includes:
- Adapter
- Defined in:
- lib/simple_crud/pagination/will_paginate_adapter.rb
Overview
Adapter for will_paginate (https://github.com/mislav/will_paginate). Uses #paginate, not #page (also defined by Kaminari).
Instance Method Summary collapse
Instance Method Details
#paginate(controller, klass, options) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/simple_crud/pagination/will_paginate_adapter.rb', line 14 def paginate(controller, klass, ) page = controller.params[:page] || 1 per_page = controller.params[:per_page] || WillPaginate.per_page records = klass.paginate(page: page, per_page: per_page) controller.render({ json: records }.merge()) end |