Module: SortHelper

Defined in:
app/helpers/sort_helper.rb

Instance Method Summary collapse

Instance Method Details


4
5
6
7
8
9
10
11
12
# File 'app/helpers/sort_helper.rb', line 4

def link_for_sort(name, field=nil)
  field ||= name.underscore
  current = (params_sort == field)
  order   = (current && (params_order == "asc")) ? "desc" : "asc"
  url     = request.path + "?sort=#{field}&order=#{order}"
  options = {}
  options.merge!(:class => "current #{order}") if current
  link_to(name, url, options)
end