Module: ApplicationHelper

Defined in:
lib/generators/fetty/views/templates/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#sortable(column, title = nil) ⇒ Object



3
4
5
6
7
8
# File 'lib/generators/fetty/views/templates/application_helper.rb', line 3

def sortable(column, title = nil)
  title ||= column.titleize
  direction = column == params[:sort] && params[:direction] == "asc" ? "desc" : "asc"
  css_class = column == params[:sort] ? "current #{direction}" : nil
  link_to title, params.merge(:sort => column, :direction => direction, :page => nil), { :class => css_class }
end