Module: Undercarriage::Controllers::KaminariConcern
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/undercarriage/controllers/kaminari_concern.rb
Overview
Kaminari pagination
Helpers for Kaminari style pagination. Note that the Kaminari gem is not loaded with dependency. It must be added to your own Gemfile
Instance Method Summary collapse
-
#page_num ⇒ Integer
Page number.
-
#per_page ⇒ Integer
Items per page.
Instance Method Details
#page_num ⇒ Integer
Page number
Will look for the Kaminari config param_name (typically page) in the URL paramaters. The result is
clamped to a minimum of 1 so a caller cannot force a negative or zero page number.
This is asseccible from the View as page_num
59 60 61 |
# File 'lib/undercarriage/controllers/kaminari_concern.rb', line 59 def page_num params.fetch(page_num_key, page_num_default).to_i.clamp(1, nil) end |
#per_page ⇒ Integer
Items per page
The number of items to return in pagination. Will use the Kaminari config default_per_page (typically 25)
for the count and will look for per in the URL paramaters to override. The result is clamped between 1
and #per_page_max so a caller cannot force an unbounded (or negative/zero) number of records per page.
This is asseccible from the View as per_page
42 43 44 |
# File 'lib/undercarriage/controllers/kaminari_concern.rb', line 42 def per_page params.fetch(per_page_key, per_page_default).to_i.clamp(1, per_page_max) end |