Sha256: 960a9f64a814ba1c7109653edebd77a9171bb061204d7e55f4ffd789d6e620ab

Contents?: true

Size: 561 Bytes

Versions: 16

Compression:

Stored size: 561 Bytes

Contents

module Formstrap
  module Pagination
    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

    def page
      if params[:page]
        params[:page]
      elsif params[:start]
        (params[:start].to_i / per_page) + 1
      else
        1
      end
    end

    def per_page
      length = params[:per_page].to_i
      (length > 0) ? length : 24
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
formstrap-0.4.5 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.4.4 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.4.3 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.4.2 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.3.5 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.3.4 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.3.3 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.3.2 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.3.1 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.3.0 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.2.1 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.2.0 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.1.3 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.1.2 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.1.1 app/controllers/concerns/formstrap/pagination.rb
formstrap-0.1.0 app/controllers/concerns/formstrap/pagination.rb