Module: Formstrap::Pagination
- Included in:
- MediaController
- Defined in:
- app/controllers/concerns/formstrap/pagination.rb
Instance Method Summary collapse
Instance Method Details
#page ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/concerns/formstrap/pagination.rb', line 12 def page if params[:page] params[:page] elsif params[:start] (params[:start].to_i / per_page) + 1 else 1 end end |
#paginate(collection) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'app/controllers/concerns/formstrap/pagination.rb', line 3 def paginate(collection) @records_filtered = collection.count if collection.is_a?(Array) Kaminari.paginate_array(collection).page(page).per(per_page) else collection.page(page).per(per_page) end end |
#per_page ⇒ Object
22 23 24 25 |
# File 'app/controllers/concerns/formstrap/pagination.rb', line 22 def per_page length = params[:per_page].to_i (length > 0) ? length : 24 end |