Skip to content

Instantly share code, notes, and snippets.

@pironim
Created July 11, 2013 13:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pironim/5975256 to your computer and use it in GitHub Desktop.
Save pironim/5975256 to your computer and use it in GitHub Desktop.
Kaminary find page for id
# You should sort by uniq column to make your results predictable
def pagination_base
current_company.projects.order('name ASC, id ASC')
end
def page_for(id)
ids = pagination_base.pluck(:id)
position = ids.index(id.to_i)
((position+1).to_f/PER_PAGE.to_f).ceil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment