summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-04-24 16:58:57 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-04-24 17:02:00 -0400
commit992dc06e50d74aca79ed58d868be6113e3ebe55c (patch)
tree0948a09823694597f49265a2ff8a3a724e5bbcc5
parent6de6d3508fdd945168f8f74072af94b3754c9386 (diff)
do away with stages_ordered
-rw-r--r--app/models/tournament.rb10
-rw-r--r--app/views/matches/index.html.erb7
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 %>