3
4
5
6
7
8
9
10
11
|
# File 'lib/bolter/helpers.rb', line 3
def sort_link(scope_name, text = nil, options = {})
as = options.fetch(:as, :sorting)
sorting = params[as] || "#{scope_name}:asc"
current_field, direction = sorting.split(':', 2).map(&:to_s)
direction = direction == 'asc' ? 'desc' : 'asc'
title = text || scope
title = title + "#{direction == 'asc' ? '▲' : '▼'}" if scope_name.to_s == current_field and params[as].present?
link_to title.html_safe, url_for(params.permit(:sorting).merge(Hash[as, "#{scope_name}:#{direction}"])), options
end
|