summaryrefslogtreecommitdiff
path: root/app/controllers/tournaments_controller.rb
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-04-22 15:50:21 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-04-22 15:50:21 -0400
commit9d226fcd27b6c2470edf718ad36a262348891470 (patch)
treebb17fce921d0017b6e9111bd81edc194c07f61d3 /app/controllers/tournaments_controller.rb
parent136b86453000aa6ad3a099efb96d85232eb2eeb5 (diff)
re-factor for tournament_stage's and separate scheduling modules
Diffstat (limited to 'app/controllers/tournaments_controller.rb')
-rw-r--r--app/controllers/tournaments_controller.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index b6f911f..4b0e1af 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -96,10 +96,13 @@ class TournamentsController < ApplicationController
when "start"
check_permission(:edit, @tournament)
@tournament.status = 1
- @tournament.save
+ ok =
+ @tournament.save &&
+ @tournament.tournament_stages.create(scheduling: "elimination") &&
+ @tournament.tournament_stages.first.create_matches
respond_to do |format|
- if @tournament.setup
- format.html { redirect_to @tournament, notice: 'You have joined this tournament.' }
+ if ok
+ format.html { redirect_to @tournament, notice: 'You have started this tournament.' }
format.json { head :no_content }
else
format.html { redirect_to @tournament, notice: "You don't have permission to start this tournament." }