API de comptabilité horaire.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

paginated.rb 363B

123456789101112
  1. module Paginated
  2. DEFAULT_COUNT_BY_PAGE = 10
  3. def self.included(includer)
  4. includer.scope :paginate, -> (params) {
  5. count_by_page = includer.respond_to?(:count_by_page) ? includer.count_by_page : DEFAULT_COUNT_BY_PAGE
  6. page = (params.fetch :page, 0).to_i
  7. start = page * count_by_page
  8. offset(start).limit(count_by_page)
  9. }
  10. end
  11. end