Skip to content

Instantly share code, notes, and snippets.

@mortik
Created April 14, 2013 12:08
Show Gist options
  • Save mortik/5382477 to your computer and use it in GitHub Desktop.
Save mortik/5382477 to your computer and use it in GitHub Desktop.
Sortable Helper for tables in Rails Dependencies: - url_plumber gem
# encoding: utf-8
module SortableHelper
def sortable column, title = nil, remote = true
title ||= column.titleize
css_class = column == sort_column ? "current #{sort_direction}" : nil
direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
link_to title, plumb(sort: column, direction: direction, page: nil), {:class => css_class}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment