Class: SimpleCrud::Pagination::WillPaginateAdapter

Inherits:
Object
  • Object
show all
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, options)
  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(options))
end