module Ransack::Helpers::FormHelper
def sort_link(search_object, attribute, *args, &block)
<% end %>
Player Name
<%= sort_link(@q, :name, [:name, 'kind ASC']) do %>
You can also use a block:
<%= sort_link(@q, :name, [:name, 'kind ASC'], 'Player Name') %>
+sort_link+
def sort_link(search_object, attribute, *args, &block) search, routing_proxy = extract_search_and_routing_proxy(search_object) unless Search === search raise TypeError, 'First argument must be a Ransack::Search!' end args[args.first.is_a?(Array) ? 1 : 0, 0] = capture(&block) if block_given? s = SortLink.new(search, attribute, args, params, &block) link_to(s.name, url(routing_proxy, s.url_options), s.html_options(args)) end