Module: SortThis::ViewHelpers::ActionView

Defined in:
lib/sort_this/view_helpers/action_view.rb

Instance Method Summary collapse

Instance Method Details

#sortable(sort_name, title = nil, html_options = {}) ⇒ Object



7
8
9
10
11
12
# File 'lib/sort_this/view_helpers/action_view.rb', line 7

def sortable(sort_name, title = nil, html_options = {})
  title ||= sort_name.titleize
  css_class = (sort_name == sort_column) ? "sortable-current sortable-#{sort_direction}" : nil
  direction = (sort_name == sort_column && sort_direction == "asc") ? "desc" : "asc"
  link_to title, params.merge(:sort => sort_name, :direction => direction), {:class => css_class}.merge(html_options)
end