module ApplicationHelper
def pagination_for(list, options={})
options are passed through to will_paginate
returns the usual set of pagination links.
def pagination_for(list, options={}) if list.respond_to? :total_pages options = { :max_per_page => @trusty_config['pagination.max_per_page'] || 500, :depaginate => true }.merge(options.symbolize_keys) depaginate = options.delete(:depaginate) # supply :depaginate => false to omit the 'show all' link depagination_limit = options.delete(:max_per_page) # supply :max_per_page => false to include the 'show all' link no matter how large the collection html = will_paginate(list, will_paginate_options.merge(options)) if depaginate && list.total_pages > 1 && (!depagination_limit.blank? || list.total_entries <= depagination_limit.to_i) html << content_tag(:div, link_to(t('show_all'), :pp => 'all'), :class => 'depaginate') elsif depaginate && list.total_entries > depagination_limit.to_i html = content_tag(:div, link_to("paginate", :p => 1), :class => 'pagination') end html end end