diff options
-rw-r--r-- | app/models/tournament.rb | 10 | ||||
-rw-r--r-- | app/views/matches/index.html.erb | 7 |
2 files changed, 3 insertions, 14 deletions
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 @@ </tr> </thead> <tbody> - <% @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| %><tr> <% match = stage.matches_ordered[match_key] %> <td><%= "Match #{match.id}" %></td> @@ -36,6 +35,6 @@ <br> -<% @tournament.stages_ordered.keys.sort.each do |stage_key| %> - <div class="graph"><%= raw @tournament.stages_ordered[stage_key].to_svg(current_user) %></div> +<% @tournament.tournament_stages.ordered(:id).each do |stage| %> + <div class="graph"><%= raw stage.to_svg(current_user) %></div> <% end %> |