cartodb-4.42/app/models/carto/paged_model.rb
2024-04-06 05:25:13 +00:00

16 lines
389 B
Ruby

module Carto
module PagedModel
def paged(page = 1, per_page = 20, order = nil)
self.paged_association(self, page, per_page, order)
end
def self.paged_association(association, page = 1, per_page = 20, order = nil)
paged = association.offset((page - 1) * per_page).limit(per_page)
paged = paged.order(order) unless order.nil?
paged
end
end
end