Sha256: d8a858e338f2fb1aa88caf4c52f8a45b2e8c19f34087c218707c6f40d9d26e31

Contents?: true

Size: 453 Bytes

Versions: 2

Compression:

Stored size: 453 Bytes

Contents

module Headmin
  module Pagination
    def paginate(collection)
      @records_filtered = collection.count
      collection.page(page).per(per_page)
    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] || params[:length]).to_i
      length > 0 ? length : 24
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
headmin-0.1.2 app/controllers/concerns/headmin/pagination.rb
headmin-0.1.1 app/controllers/concerns/headmin/pagination.rb