Method: Ransack::Helpers::FormHelper#sort_link
- Defined in:
- lib/ransack/helpers/form_helper.rb
#sort_link(search_object, attribute, *args, &block) ⇒ Object
sort_link
<%= sort_link(@q, :name, [:name, 'kind ASC'], 'Player Name') %>
You can also use a block:
<%= sort_link(@q, :name, [:name, 'kind ASC']) do %>
<strong>Player Name</strong>
<% end %>
47 48 49 50 51 52 53 54 55 |
# File 'lib/ransack/helpers/form_helper.rb', line 47 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.), s.(args)) end |