Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def paginate(collection, controller, action)
- return if collection.empty?
- if collection.total_pages > collection.per_page
- html = 1.upto(collection.total_pages).map { |i|
- options = { :page => i }
- options.merge!(:q => params[:q]) if params[:q].present?
- link_to(i, url(controller, action, options), :class => [(params[:page].to_i == i ? :current : :page), ' link'])
- }.join
- content_tag(:div, html, :class => "pagination")
- end
- end
Add Comment
Please, Sign In to add comment