diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 0e5da20..5b611aa 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -8,10 +8,11 @@ class StaticPagesController < ApplicationController @tournament = Tournament.find(params[:tournament]) end if @tournament - if @tournamnet.matches == nil - render 'noMatches' + if @tournament.matches.empty? + redirect_to "/static_pages/noMatches?tournament=#{@tournament.id}" + else + @matches = @tournament.upcomingMatches end - @matches = @tournament.upcomingMatches end end @@ -38,13 +39,14 @@ class StaticPagesController < ApplicationController def brackets if params[:weight] @weight = Weight.find(params[:weight]) - @bracketType = @weight.pool_bracket_type @tournament = Tournament.find(@weight.tournament_id) @matches = @tournament.matches.select{|m| m.weight_id == @weight.id} @wrestlers = Wrestler.where(weight_id: @weight.id) - @pools = @weight.poolRounds(@matches) - if @matches == nil or @wrestlers == nil - render 'noMatches' + if @matches.empty? or @wrestlers.empty? + redirect_to "/static_pages/noMatches?tournament=#{@tournament.id}" + else + @pools = @weight.poolRounds(@matches) + @bracketType = @weight.pool_bracket_type end end end @@ -64,4 +66,10 @@ class StaticPagesController < ApplicationController @weights = @weights.sort_by{|x|[x.max]} end end + + def noMatches + if params[:tournament] + @tournament = Tournament.find(params[:tournament]) + end + end end diff --git a/app/views/tournaments/_noMatches.html.erb b/app/views/static_pages/noMatches.html.erb similarity index 56% rename from app/views/tournaments/_noMatches.html.erb rename to app/views/static_pages/noMatches.html.erb index f9bd439..d0d0fb8 100644 --- a/app/views/tournaments/_noMatches.html.erb +++ b/app/views/static_pages/noMatches.html.erb @@ -1,2 +1,5 @@ +<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}" %> +
+

No Matches

This view will not render until matches have been generated by the tournament director.

\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 0ffd4ae..e3962af 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -29,6 +29,7 @@ Wrestling::Application.routes.draw do get 'static_pages/control_match' get 'static_pages/results' get 'static_pages/team_scores' + get 'static_pages/noMatches' # Example of regular route: