Skip to content

Instantly share code, notes, and snippets.

@jnunemaker
Last active December 11, 2015 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnunemaker/4541827 to your computer and use it in GitHub Desktop.
Save jnunemaker/4541827 to your computer and use it in GitHub Desktop.
Paginate without the count for plucky. Probably doesn't work with will paginate, but if you just have previous / next it works great and avoids expensive count calls.
Plucky::Query.class_eval do
def paginate_without_total(opts={})
page = (opts.delete(:page) || 1).to_i
limit = (opts.delete(:per_page) || per_page).to_i
skip = (page - 1) * limit
all(opts.merge(:limit => limit, :skip => skip))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment