Module: Chewy::Search::Pagination::WillPaginate
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/chewy/search/pagination/will_paginate.rb
Overview
This module provides WillPaginate
support for Request
It is included automatically if WillPaginate
is available.
Instance Method Summary collapse
Instance Method Details
#page(page) ⇒ Object
27 28 29 |
# File 'lib/chewy/search/pagination/will_paginate.rb', line 27 def page(page) paginate(page: page) end |
#paginate(options = {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/chewy/search/pagination/will_paginate.rb', line 18 def paginate( = {}) @current_page = ::WillPaginate::PageNumber([:page] || @current_page || 1) @page_multiplier = @current_page - 1 @per_page = ([:per_page] || @per_page || ::WillPaginate.per_page).to_i # call Chewy::Query methods to limit results limit(@per_page).offset(@page_multiplier * @per_page) end |