From b62d43ccde70aa6fccf5341e57a695a2cfb289c1 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 13 Mar 2019 15:48:14 -0400 Subject: Game list is sortable --- app/helpers/application_helper.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/helpers') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a8b1c7e..8008b04 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,4 +4,11 @@ module ApplicationHelper content_for :title, text end + def sortable(col, title = nil) + title ||= col.titleize + css_class = (col == sort_column) ? "current #{sort_direction}" : nil + direction = (col == sort_column and sort_direction == "asc") ? "desc" : "asc" + link_to title, {:sort => col, :dir => direction}, {:class => css_class} + end + end -- cgit 1.4.1