summaryrefslogtreecommitdiff
path: root/app/views/matches
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/matches')
-rw-r--r--app/views/matches/_form.html.erb15
-rw-r--r--app/views/matches/index.html.erb10
-rw-r--r--app/views/matches/new.html.erb2
-rw-r--r--app/views/matches/show.html.erb29
4 files changed, 30 insertions, 26 deletions
diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb
index f1e6047..67d30da 100644
--- a/app/views/matches/_form.html.erb
+++ b/app/views/matches/_form.html.erb
@@ -1,16 +1,5 @@
-<%= form_for(@match) do |f| %>
- <% if @match.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:</h2>
-
- <ul>
- <% @match.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
-
+<%= form_for([@tournament, @tournament.matches.build]) do |f| %>
+
<div class="field">
<%= f.label :tournament_id %><br>
<%= f.text_field :tournament_id %>
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb
index 71db08c..ff42ef1 100644
--- a/app/views/matches/index.html.erb
+++ b/app/views/matches/index.html.erb
@@ -13,14 +13,14 @@
</thead>
<tbody>
- <% @matches.each do |match| %>
+ <% @tournament.matches.each do |match| %>
<tr>
<td><%= match.tournament %></td>
<td><%= match.name %></td>
<td><%= match.winner %></td>
- <td><%= link_to 'Show', match %></td>
- <td><%= link_to 'Edit', edit_match_path(match) %></td>
- <td><%= link_to 'Destroy', match, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ <td><%= link_to 'Show', tournament_match_path(@tournament, match) %></td>
+ <td><%= link_to 'Edit', edit_tournament_match_path(@tournament, match) %></td>
+ <td><%= link_to 'Destroy', tournament_match_path(@tournament, match), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
@@ -28,4 +28,4 @@
<br>
-<%= link_to 'New Match', new_match_path %>
+<%= link_to 'New Match', new_tournament_match_path %>
diff --git a/app/views/matches/new.html.erb b/app/views/matches/new.html.erb
index bd4c78c..9ac669f 100644
--- a/app/views/matches/new.html.erb
+++ b/app/views/matches/new.html.erb
@@ -2,4 +2,4 @@
<%= render 'form' %>
-<%= link_to 'Back', matches_path %>
+
diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb
index 3abb1f7..d8112b7 100644
--- a/app/views/matches/show.html.erb
+++ b/app/views/matches/show.html.erb
@@ -1,8 +1,6 @@
-<p id="notice"><%= notice %></p>
-
<p>
<strong>Tournament:</strong>
- <%= @match.tournament %>
+ <%= @match.tournament.id %>
</p>
<p>
@@ -10,10 +8,27 @@
<%= @match.name %>
</p>
-<p>
- <strong>Winner:</strong>
- <%= @match.winner %>
-</p>
+<% if @tournament.hosts.include?(current_user) %>
+ <%= form_tag(tournament_match_path(@tournament, @match), method: "put") do %>
+ <ul>
+ <% @match.teams.each do |team| %>
+ <li><label><input type="radio" name="winner" value="<%= team.id %>">
+ <%= team.users.collect{|u| u.user_name}.join(", ") %></label></li>
+ <% end %>
+ </ul>
+ <%= submit_tag("Select winner") %>
+ <% end %>
+<% end %>
+<%= link_to 'Edit', edit_tournament_match_path(@tournament, @match) %> |
+<%= link_to 'Back', tournament_matches_path %>
+
+<% unless @match.winner.nil? %>
+ <p>
+ <strong>Winner:</strong>
+ <%= @match.winner.users.collect{|u| u.user_name}.join(", ") %>
+ </p>
+<% end %>
<%= link_to 'Edit', edit_match_path(@match) %> |
<%= link_to 'Back', matches_path %>
+