From 0c22c4bd9a0b4a0b0ff5840c1af41c0b320e3529 Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Tue, 25 Mar 2014 17:30:10 -0400 Subject: added match status --- app/views/matches/_form.html.erb | 23 +++++++++++++++++++++-- app/views/matches/index.html.erb | 14 ++++++++------ app/views/matches/index.json.jbuilder | 2 +- app/views/matches/new.html.erb | 2 ++ app/views/matches/show.html.erb | 34 ++++++++++++++-------------------- app/views/matches/show.json.jbuilder | 2 +- 6 files changed, 47 insertions(+), 30 deletions(-) (limited to 'app/views/matches') diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb index 015aed0..727c002 100644 --- a/app/views/matches/_form.html.erb +++ b/app/views/matches/_form.html.erb @@ -1,5 +1,20 @@ -<%= form_for([@tournament, @tournament.matches.build]) do |f| %> - +<%= form_for(@match) do |f| %> + <% if @match.errors.any? %> +
+

<%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :status %>
+ <%= f.number_field :status %> +
<%= f.label :tournament_id %>
<%= f.text_field :tournament_id %> @@ -8,6 +23,10 @@ <%= f.label :name %>
<%= f.text_field :name %>
+
+ <%= f.label :winner_id %>
+ <%= f.text_field :winner_id %> +
<%= f.submit %>
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 60df1b5..400efb4 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -3,6 +3,7 @@ + @@ -13,14 +14,15 @@ - <% @tournament.matches.each do |match| %> + <% @matches.each do |match| %> - + + - - - + + + <% end %> @@ -28,4 +30,4 @@
-<%= link_to 'New Match', new_tournament_match_path %> +<%= link_to 'New Match', new_match_path %> diff --git a/app/views/matches/index.json.jbuilder b/app/views/matches/index.json.jbuilder index 0b2bfcd..1a63f5f 100644 --- a/app/views/matches/index.json.jbuilder +++ b/app/views/matches/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@matches) do |match| - json.extract! match, :id, :tournament_id, :name, :winner_id + json.extract! match, :id, :status, :tournament_id, :name, :winner_id json.url match_url(match, format: :json) end diff --git a/app/views/matches/new.html.erb b/app/views/matches/new.html.erb index 74e7e3a..bd4c78c 100644 --- a/app/views/matches/new.html.erb +++ b/app/views/matches/new.html.erb @@ -1,3 +1,5 @@

New match

<%= render 'form' %> + +<%= link_to 'Back', matches_path %> diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index b6930ea..f3fc822 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -1,6 +1,13 @@ +

<%= notice %>

+ +

+ Status: + <%= @match.status %> +

+

Tournament: - <%= @match.tournament.id %> + <%= @match.tournament %>

@@ -8,23 +15,10 @@ <%= @match.name %>

-<% if (@tournament.hosts.include?(current_user) and @match.winner.nil?) %> - <%= form_for([@tournament, @match], method: "put") do |f| %> - - <%= f.submit("Select winner") %> - <% end %> -<% end %> - -<% unless @match.winner.nil? %> -

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

-<% end %> +

+ Winner: + <%= @match.winner %> +

-<%= link_to 'Back', tournament_matches_path %> +<%= link_to 'Edit', edit_match_path(@match) %> | +<%= link_to 'Back', matches_path %> diff --git a/app/views/matches/show.json.jbuilder b/app/views/matches/show.json.jbuilder index fe14010..a3ef588 100644 --- a/app/views/matches/show.json.jbuilder +++ b/app/views/matches/show.json.jbuilder @@ -1 +1 @@ -json.extract! @match, :id, :tournament_id, :name, :winner_id, :created_at, :updated_at +json.extract! @match, :id, :status, :tournament_id, :name, :winner_id, :created_at, :updated_at -- cgit v1.2.3-54-g00ecf
Status Tournament Name Winner
<%= match.tournament.id %><%= match.status %><%= match.tournament %> <%= match.name %> <%= match.winner %><%= link_to 'Show', tournament_match_path(@tournament, match) %><%= link_to 'Edit', edit_tournament_match_path(@tournament, match) %><%= link_to 'Destroy', tournament_match_path(@tournament, match), method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Show', match %><%= link_to 'Edit', edit_match_path(match) %><%= link_to 'Destroy', match, method: :delete, data: { confirm: 'Are you sure?' } %>