Module: Kaminari::PageScopeMethods::InstanceMethods
- Defined in:
- lib/kaminari/models/page_scope_methods.rb
Instance Method Summary collapse
-
#current_page ⇒ Object
Current page number.
-
#num_pages ⇒ Object
Total number of pages.
-
#per(num) ⇒ Object
Specify the
per_page
value for the precedingpage
scope Model.page(3).per(10).
Instance Method Details
#current_page ⇒ Object
Current page number
21 22 23 |
# File 'lib/kaminari/models/page_scope_methods.rb', line 21 def current_page (offset_value / limit_value) + 1 end |
#num_pages ⇒ Object
Total number of pages
16 17 18 |
# File 'lib/kaminari/models/page_scope_methods.rb', line 16 def num_pages (total_count.to_f / limit_value).ceil end |
#per(num) ⇒ Object
Specify the per_page
value for the preceding page
scope
Model.page(3).per(10)
7 8 9 10 11 12 13 |
# File 'lib/kaminari/models/page_scope_methods.rb', line 7 def per(num) if (n = num.to_i) <= 0 self else limit(n).offset(offset_value / limit_value * n) end end |