Skip to content

Instantly share code, notes, and snippets.

@tal
Created July 17, 2012 16:10
Show Gist options
  • Select an option

  • Save tal/3130341 to your computer and use it in GitHub Desktop.

Select an option

Save tal/3130341 to your computer and use it in GitHub Desktop.
module RequestPagination
def self.included(klass)
klass.scope :paginate_from, ->(request,limit=nil) do
dset = self
if id = request.headers['X-delight-lt-id']
dset = dset.where(:_id.lt => id)
end
if limit = request.headers['X-delight-item-limit']||limit
dset = dset.limit(limit)
end
dset
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment