From 992dc06e50d74aca79ed58d868be6113e3ebe55c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 24 Apr 2014 16:58:57 -0400 Subject: do away with stages_ordered --- app/models/tournament.rb | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'app/models/tournament.rb') diff --git a/app/models/tournament.rb b/app/models/tournament.rb index e21ccb1..caa711c 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -5,16 +5,6 @@ class Tournament < ActiveRecord::Base has_and_belongs_to_many :players, class_name: "User", association_foreign_key: "player_id", join_table: "players_tournaments" has_and_belongs_to_many :hosts, class_name: "User", association_foreign_key: "host_id", join_table: "hosts_tournaments" - def stages_ordered - h = {} - i = 1 - self.tournament_stages.order(:id).each do |s| - h[i] = s - i += 1 - end - return h - end - def settings @settings ||= Settings.new(self) end -- cgit v1.2.3-54-g00ecf From 27c3e207b299e6c5a94a1ab81412bb9e11a0d92a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 24 Apr 2014 17:01:42 -0400 Subject: rename Tournament#tournament_stages to Tournament#stages --- app/controllers/tournaments_controller.rb | 4 ++-- app/models/tournament.rb | 2 +- app/views/matches/index.html.erb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'app/models/tournament.rb') diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index ebc54c1..1354ad6 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -116,8 +116,8 @@ class TournamentsController < ApplicationController success = true ActiveRecord::Base.transaction do success &= @tournament.save && - success &= @tournament.tournament_stages.create(scheduling: "elimination") - success &= @tournament.tournament_stages.first.create_matches + success &= @tournament.stages.create(scheduling: "elimination") + success &= @tournament.stages.first.create_matches end if success format.html { redirect_to @tournament, notice: 'You have started this tournament.' } diff --git a/app/models/tournament.rb b/app/models/tournament.rb index caa711c..861be6c 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -1,6 +1,6 @@ class Tournament < ActiveRecord::Base belongs_to :game - has_many :tournament_stages + has_many :stages, class_name: "TournamentStage" has_many :settings_raw, class_name: "TournamentSetting" has_and_belongs_to_many :players, class_name: "User", association_foreign_key: "player_id", join_table: "players_tournaments" has_and_belongs_to_many :hosts, class_name: "User", association_foreign_key: "host_id", join_table: "hosts_tournaments" diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index d8538df..761f12a 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -12,7 +12,7 @@ - <% @tournament.tournament_stages.ordered(:id)each do |stage| %> + <% @tournament.stages.ordered(:id)each do |stage| %> <% stage.matches_ordered.keys.sort.reverse.each do |match_key| %> <% match = stage.matches_ordered[match_key] %> <%= "Match #{match.id}" %> @@ -35,6 +35,6 @@
-<% @tournament.tournament_stages.ordered(:id).each do |stage| %> +<% @tournament.stages.ordered(:id).each do |stage| %>
<%= raw stage.to_svg(current_user) %>
<% end %> -- cgit v1.2.3-54-g00ecf