about summary refs log tree commit diff stats
path: root/app/controllers/games_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/games_controller.rb')
-rw-r--r--app/controllers/games_controller.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 8ddcf24..dcbe226 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb
@@ -1,9 +1,21 @@
1class GamesController < ApplicationController 1class GamesController < ApplicationController
2 helper_method :sort_column, :sort_direction
3
2 def index 4 def index
3 @games = Game.order(started_on: :desc) 5 @games = Game.order(sort_column + " " + sort_direction)
4 6
5 if params[:status] 7 if params[:status]
6 @games = @games.where(status: params[:status]) 8 @games = @games.where(status: params[:status])
7 end 9 end
8 end 10 end
11
12 private
13
14 def sort_column
15 Game.column_names.include?(params[:sort]) ? params[:sort] : "started_on"
16 end
17
18 def sort_direction
19 %[asc desc].include?(params[:dir]) ? params[:dir] : "asc"
20 end
9end 21end