Guest User

Untitled

a guest
May 25th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. def paginate(collection, controller, action)
  2. return if collection.empty?
  3. if collection.total_pages > collection.per_page
  4. html = 1.upto(collection.total_pages).map { |i|
  5. options = { :page => i }
  6. options.merge!(:q => params[:q]) if params[:q].present?
  7. link_to(i, url(controller, action, options), :class => [(params[:page].to_i == i ? :current : :page), ' link'])
  8. }.join
  9. content_tag(:div, html, :class => "pagination")
  10. end
  11. end
Add Comment
Please, Sign In to add comment