From f69fcc28596700c1a875068b7cb616d6eb40e6df Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 7 Mar 2014 01:25:12 -0500 Subject: It is 1:30 AM --- app/controllers/matches_controller.rb | 2 +- app/models/match.rb | 2 +- app/models/tournament.rb | 4 ++-- app/views/matches/show.html.erb | 12 ++++-------- 4 files changed, 8 insertions(+), 12 deletions(-) (limited to 'app') diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 986bb44..1f0d964 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -42,7 +42,7 @@ class MatchesController < ApplicationController def update respond_to do |format| if @match.update(match_params) - format.html { redirect_to @match, notice: 'Match was successfully updated.' } + format.html { redirect_to [@tournament, @match], notice: 'Match was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } diff --git a/app/models/match.rb b/app/models/match.rb index 7dacae5..782dce8 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -3,6 +3,6 @@ class Match < ActiveRecord::Base has_and_belongs_to_many :teams - belongs_to :winner + belongs_to :winner, class_name: "Team" end diff --git a/app/models/tournament.rb b/app/models/tournament.rb index ead9205..79d8b24 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -16,7 +16,7 @@ class Tournament < ActiveRecord::Base unless joinable_by?(user) return false end - players<

-<% if @tournament.hosts.include?(current_user) %> - <%= form_for(@match, method: "put") do |f| %> +<% if (@tournament.hosts.include?(current_user) and @match.winner.nil?) %> + <%= form_for([@tournament, @match], method: "put") do |f| %> @@ -20,15 +20,11 @@ <% end %> <% end %> -<%= link_to 'Edit', edit_tournament_match_path(@tournament, @match) %> | -<%= link_to 'Back', tournament_matches_path %> - <% unless @match.winner.nil? %>

Winner: <%= @match.winner.users.collect{|u| u.user_name}.join(", ") %>

<% end %> -<%= link_to 'Edit', edit_match_path(@match) %> | -<%= link_to 'Back', matches_path %> +<%= link_to 'Back', tournament_matches_path %> -- cgit v1.2.3-2-g168b