From ae9a64f4e2e7a654e28744f1c8ca98681bb70301 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 24 Apr 2014 16:28:14 -0400 Subject: run ./generate.sh --- app/models/api_request.rb | 2 ++ app/models/api_requests.rb | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 app/models/api_request.rb delete mode 100644 app/models/api_requests.rb (limited to 'app') diff --git a/app/models/api_request.rb b/app/models/api_request.rb new file mode 100644 index 0000000..ffb7267 --- /dev/null +++ b/app/models/api_request.rb @@ -0,0 +1,2 @@ +class ApiRequest < ActiveRecord::Base +end diff --git a/app/models/api_requests.rb b/app/models/api_requests.rb deleted file mode 100644 index 19c76e2..0000000 --- a/app/models/api_requests.rb +++ /dev/null @@ -1,2 +0,0 @@ -class ApiRequests < ActiveRecord::Base -end -- cgit v1.2.3-54-g00ecf 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 ---------- app/views/matches/index.html.erb | 7 +++---- 2 files changed, 3 insertions(+), 14 deletions(-) (limited to 'app') 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 diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 8a50fee..d8538df 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -12,8 +12,7 @@ - <% @tournament.stages_ordered.keys.sort.each do |stage_key| %> - <% stage = @tournament.stages_ordered[stage_key] %> + <% @tournament.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}" %> @@ -36,6 +35,6 @@
-<% @tournament.stages_ordered.keys.sort.each do |stage_key| %> -
<%= raw @tournament.stages_ordered[stage_key].to_svg(current_user) %>
+<% @tournament.tournament_stages.ordered(:id).each do |stage| %> +
<%= raw stage.to_svg(current_user) %>
<% 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') 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 From 976325f60e7706e480f3d45848897200734c8485 Mon Sep 17 00:00:00 2001 From: tkimia Date: Thu, 24 Apr 2014 17:46:09 -0400 Subject: luke's typo fix --- app/views/matches/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 761f12a..784d7db 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -12,7 +12,7 @@ - <% @tournament.stages.ordered(:id)each do |stage| %> + <% @tournament.stages.order(: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.stages.ordered(:id).each do |stage| %> +<% @tournament.stages.order(:id).each do |stage| %>
<%= raw stage.to_svg(current_user) %>
<% end %> -- cgit v1.2.3-54-g00ecf