summaryrefslogtreecommitdiff
path: root/app/controllers/tournaments_controller.rb
diff options
context:
space:
mode:
authornfoy <nfoy@purdue.edu>2014-04-23 20:41:03 -0400
committernfoy <nfoy@purdue.edu>2014-04-23 20:41:03 -0400
commit9afd5a4f7a86eeaab3fa8a0c25609ac7977e0489 (patch)
tree8d47adc08a58a8936e2026f30852f877ee47cf64 /app/controllers/tournaments_controller.rb
parent422a7b39a06e2fe54415f2be08548021a981e8a8 (diff)
parent7ff82b901705475f97e277a9f3f31756bd3ce948 (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app/controllers/tournaments_controller.rb')
-rw-r--r--app/controllers/tournaments_controller.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 03dc5b8..b276368 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -32,7 +32,11 @@ class TournamentsController < ApplicationController
# GET /tournaments/new
def new
@games = Game.all
- @tournament = Tournament.new(game: Game.find_by_id(params[:game]))
+ if params[:tournament]
+ @tournament = Tournament.new(game: Game.find(params[:tournament][:game_id]))
+ else
+ @tournament = Tournament.new()
+ end
end
# GET /tournaments/1/edit
@@ -146,7 +150,12 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_params
- params.require(:tournament).permit(:game, :game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method)
+ permitted = [:game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method]
+ if params[:tournament][:game_id]
+ game = Game.find(params[:tournament][:game_id])
+ permitted.push(:settings => game.settings.collect{|s| s.name})
+ end
+ params.require(:tournament).permit(permitted)
end
def is_owner?(object)