OpenProject is the leading open source project management software.
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.
 
 
 
 
 
 
openproject/lib/timelines/pagination/model.rb

27 lines
743 B

# This module includes some boilerplate code for pagination using scopes.
# #search_scope has to be overridden by the model itself and MUST return an
# actual scope (i.e. scope in Rails3 or named_scope in Rails2) or its corresponding hash.
module Timelines::Pagination::Model
def self.included(base)
base.extend self
end
def self.extended(base)
base.instance_eval do
unloadable
def paginate_scope!(scope, options = {})
limit = options.fetch(:page_limit) || 10
page = options.fetch(:page) || 1
scope.paginate({ :per_page => limit, :page => page })
end
def search_scope(query)
raise NotImplementedError, "Override in subclass #{self.name}"
end
end
end
end