module Paginated DEFAULT_COUNT_BY_PAGE = 10 # can be overwritten def count_by_page DEFAULT_COUNT_BY_PAGE end def paginate(params) page = (params.fetch :page, 0).to_i start = page * count_by_page offset(start).limit(count_by_page) end end