Module: Sorty::Helpers
- Included in:
- ApplicationHelper
- Defined in:
- lib/sorty/helpers.rb
Instance Method Summary collapse
Instance Method Details
#sorty(column, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/sorty/helpers.rb', line 3 def sorty(column, = {}) = { :label => column.to_s.humanize.titleize }.merge() query = params.merge({ column: column, direction: (params[:direction].eql?('asc') ? 'desc' : 'asc') }) if params[:column].eql?(column.to_s) [:label] << (params[:direction].eql?('asc') ? ' ↑' : ' ↓') end link_to(raw([:label]), query) end |