From 442146c7160b95d452975336dfddaf8faf74d544 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Sun, 27 Apr 2014 14:22:17 -0400 Subject: fixed, seeds, roundrobin, and _show_tourn --- app/controllers/tournaments_controller.rb | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 8752298..c212273 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -15,7 +15,8 @@ class TournamentsController < ApplicationController when 0 render action: 'show' when 1 - redirect_to tournament_matches_path(@tournament) + #redirect_to tournament_matches_page(@tournament) + redirect_to "/tournaments/" + @tournament.id.to_s + "/matches" when 2 redirect_to tournaments_page end @@ -50,20 +51,11 @@ class TournamentsController < ApplicationController 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)) - rescue ActionController::ParameterMissing => e - ok = false - @tournament.errors.add("stages[#{i}]", "Stage #{i} not set") - end + ok &= @tournament.stages.create(tournament_stage_params(i)) end end - rescue ActiveRecord::RecordNotUnique => e - ok = false - @tournament.errors.add(:name, "must be unique") - rescue => e + rescue ok = false - @tournament.errors.add(:exception, "Unknown error: ``#{e.class.name}'' -- #{e.inspect} -- #{e.methods - Object.new.methods}") end respond_to do |format| if ok @@ -134,7 +126,7 @@ class TournamentsController < ApplicationController ActiveRecord::Base.transaction do success &= @tournament.save && sched = tournament_attribute_params[:type_opt] - success &= @tournament.stages.create(scheduling: sched) + success &= @tournament.stages.create(scheduling_method: sched) success &= @tournament.stages.first.create_matches end if success @@ -179,9 +171,8 @@ class TournamentsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def tournament_attribute_params - params[:num_stages] ||= 1 if params[:tournament] - p = params.require(:tournament).permit(:game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :sampling_method, :scoring_method) + p = params.require(:tournament).permit(: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, :scoring_method) if p[:game_id] game = Game.find(p[:game_id]) p[:min_players_per_team] ||= game.min_players_per_team @@ -207,7 +198,7 @@ class TournamentsController < ApplicationController end def tournament_stage_params(i) - params.require(:tournament).require(:stages).require(i.to_s).permit(:scheduling_method, :seeding_method) + params.require(:tournament).require(i.to_sym).permit(:scheduling_method, :seeding_method) end def is_owner?(object) -- cgit v1.2.3