Module: WillSortate::ActionViewExtension

Defined in:
lib/will_sortate/helpers/action_view_extension.rb

Instance Method Summary collapse

Instance Method Details



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/will_sortate/helpers/action_view_extension.rb', line 4

def sortate_link_to *args, &block
  if block_given?
    collection, field, options = args[0], args[1], args[2]
  else
    block = proc { args[0].to_s }
    collection, field, options = args[1], args[2], args[3]
  end
  helper = SorterHelper.new :collection         => collection,
                            :sort_field         => field,
                            :default_sort_order => options.try(:delete, :default_sort_order),
                            :params             => params
  link_to url_for(helper.params), options, &block
end