From 284439e2cfcc2a79f727cb23a6874cdf3b024773 Mon Sep 17 00:00:00 2001 From: RJ Osborne Date: Thu, 28 May 2015 00:25:14 -0400 Subject: [PATCH] Removed upcomingMatches because matches are an A-R relation of Tournament --- app/controllers/static_pages_controller.rb | 17 ++++++++--------- app/models/tournament.rb | 4 ---- app/views/static_pages/all_brackets.html.erb | 8 ++++---- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 2b3d3da..77d8e7b 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -8,10 +8,9 @@ class StaticPagesController < ApplicationController @tournament = Tournament.find(params[:tournament]) end if @tournament - if @tournament.matches.empty? + @matches = @tournament.matches + if @matches.empty? redirect_to "/static_pages/noMatches?tournament=#{@tournament.id}" - else - @matches = @tournament.upcomingMatches end end end @@ -30,12 +29,12 @@ class StaticPagesController < ApplicationController if params[:tournament] @tournament = Tournament.find(params[:tournament]) end - if @tournament - @matches = Match.where(tournament_id: @tournament.id) - end + if @tournament + @matches = @tournament.matches + end @matches = @matches.where(finished: 1) - end + def brackets if params[:weight] @weight = Weight.find(params[:weight]) @@ -50,7 +49,7 @@ class StaticPagesController < ApplicationController end end end - + def all_brackets if params[:tournament] @tournament = Tournament.find(params[:tournament]) @@ -85,7 +84,7 @@ class StaticPagesController < ApplicationController @tournament = Tournament.find(params[:tournament]) end end - + def generate_matches if !user_signed_in? redirect_to root_path diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 5d935dd..a103274 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -24,10 +24,6 @@ class Tournament < ActiveRecord::Base end end - def upcomingMatches - matches - end - def destroyAllMatches matches.destroy_all end diff --git a/app/views/static_pages/all_brackets.html.erb b/app/views/static_pages/all_brackets.html.erb index 8e712e6..57c013e 100644 --- a/app/views/static_pages/all_brackets.html.erb +++ b/app/views/static_pages/all_brackets.html.erb @@ -1,5 +1,5 @@ @@ -26,11 +26,11 @@ <% @tournament.weights.sort_by{|w| w.max}.each do |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) %> <% @pools = w.poolRounds(@matches) %>
<%= @weight.max %> lbs Bracket
- + <%= render 'pool' %>
@@ -48,4 +48,4 @@ <% end %>
<% end %> - \ No newline at end of file +