diff options
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/paginable.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/concerns/paginable.rb b/app/models/concerns/paginable.rb index 66695677e..52f186918 100644 --- a/app/models/concerns/paginable.rb +++ b/app/models/concerns/paginable.rb @@ -19,5 +19,13 @@ module Paginable query = query.where(arel_table[:id].gt(min_id)) if min_id.present? query } + + scope :paginate_by_id, ->(limit, **options) { + if options[:min_id].present? + paginate_by_min_id(limit, options[:min_id]).reverse + else + paginate_by_max_id(limit, options[:max_id], options[:since_id]) + end + } end end |