1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-04 22:03:49 +00:00

Removed upcomingMatches because matches are an A-R relation of Tournament

This commit is contained in:
RJ Osborne
2015-05-28 00:25:14 -04:00
parent 062396da0a
commit 284439e2cf
3 changed files with 12 additions and 17 deletions

View File

@@ -8,10 +8,9 @@ class StaticPagesController < ApplicationController
@tournament = Tournament.find(params[:tournament]) @tournament = Tournament.find(params[:tournament])
end end
if @tournament if @tournament
if @tournament.matches.empty? @matches = @tournament.matches
if @matches.empty?
redirect_to "/static_pages/noMatches?tournament=#{@tournament.id}" redirect_to "/static_pages/noMatches?tournament=#{@tournament.id}"
else
@matches = @tournament.upcomingMatches
end end
end end
end end
@@ -30,12 +29,12 @@ class StaticPagesController < ApplicationController
if params[:tournament] if params[:tournament]
@tournament = Tournament.find(params[:tournament]) @tournament = Tournament.find(params[:tournament])
end end
if @tournament if @tournament
@matches = Match.where(tournament_id: @tournament.id) @matches = @tournament.matches
end end
@matches = @matches.where(finished: 1) @matches = @matches.where(finished: 1)
end end
def brackets def brackets
if params[:weight] if params[:weight]
@weight = Weight.find(params[:weight]) @weight = Weight.find(params[:weight])
@@ -50,7 +49,7 @@ class StaticPagesController < ApplicationController
end end
end end
end end
def all_brackets def all_brackets
if params[:tournament] if params[:tournament]
@tournament = Tournament.find(params[:tournament]) @tournament = Tournament.find(params[:tournament])
@@ -85,7 +84,7 @@ class StaticPagesController < ApplicationController
@tournament = Tournament.find(params[:tournament]) @tournament = Tournament.find(params[:tournament])
end end
end end
def generate_matches def generate_matches
if !user_signed_in? if !user_signed_in?
redirect_to root_path redirect_to root_path

View File

@@ -24,10 +24,6 @@ class Tournament < ActiveRecord::Base
end end
end end
def upcomingMatches
matches
end
def destroyAllMatches def destroyAllMatches
matches.destroy_all matches.destroy_all
end end

View File

@@ -1,5 +1,5 @@
<style> <style>
.pagebreak { page-break-after: always; width:100%;} .pagebreak { page-break-after: always; width:100%;}
#html, #body, #wrapper { width:100%; } #html, #body, #wrapper { width:100%; }
</style> </style>
@@ -26,11 +26,11 @@
<% @tournament.weights.sort_by{|w| w.max}.each do |w| %> <% @tournament.weights.sort_by{|w| w.max}.each do |w| %>
<div class="pagebreak"> <div class="pagebreak">
<% @weight = w %> <% @weight = w %>
<% @matches = @tournament.upcomingMatches.select{|m| m.weight_id == @weight.id} %> <% @matches = @tournament.matches.select{|m| m.weight_id == @weight.id} %>
<% @wrestlers = Wrestler.where(weight_id: @weight.id) %> <% @wrestlers = Wrestler.where(weight_id: @weight.id) %>
<% @pools = w.poolRounds(@matches) %> <% @pools = w.poolRounds(@matches) %>
<h5><%= @weight.max %> lbs Bracket</h5> <h5><%= @weight.max %> lbs Bracket</h5>
<%= render 'pool' %> <%= render 'pool' %>
</div> </div>
<div class="pagebreak"> <div class="pagebreak">
@@ -48,4 +48,4 @@
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
</div> </div>