diff options
author | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-27 20:47:42 -0400 |
---|---|---|
committer | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-27 20:47:42 -0400 |
commit | 4d47e5e7b5d838173dd3ab68c293c03e03811392 (patch) | |
tree | 594659a4fbc6cbc1afd188f94f8196e203cabe31 /app/controllers/tournaments_controller.rb | |
parent | df1cda1faab97f4c424efdcf8b6822f98b73adb8 (diff) | |
parent | 9d0be853cef35412c0bfe92c80502fd9da7947f1 (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.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 9c8ad7a..2e854a2 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -31,6 +31,17 @@ class TournamentsController < ApplicationController # GET /tournaments/new def new @tournament = Tournament.new(tournament_attribute_params) + if @tournament.game + @tournament.game.settings.each do |game_setting| + @tournament.tournament_settings.build( + name: game_setting.name, + value: game_setting.value, + vartype: game_setting.vartype, + type_opt: game_setting.type_opt, + description: game_setting.description, + display_order: game_setting.display_order) + end + end end # GET /tournaments/1/edit @@ -46,17 +57,17 @@ class TournamentsController < ApplicationController ok = true begin ActiveRecord::Base.transaction do - ok &= @tournament.save ok &= @tournament.update(tournament_setting_params) ok &= @tournament.hosts.push(current_user) for i in 1..(params[:num_stages].to_i) do begin - ok &= @tournament.stages.create(tournament_stage_params(i)) + ok &= @tournament.stages.build(tournament_stage_params(i)) rescue ActionController::ParameterMissing => e ok = false - @tournament.errors.add("stages[#{i}]", "Stage #{i} not set") + @tournament.errors.add("stages[#{i}]", "needs to be set") end end + ok &= @tournament.save end rescue ActiveRecord::RecordNotUnique => e ok = false |