From 0867bc68749873aa131c0f3b273771b5f70ae778 Mon Sep 17 00:00:00 2001 From: Tomer Kimia Date: Tue, 1 Apr 2014 17:14:05 -0400 Subject: players can now leave tournaments --- app/views/tournaments/show.html.erb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'app/views/tournaments/show.html.erb') diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index cc0f0e3..df85dcf 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -71,10 +71,17 @@ <%= submit_tag("Join Tournamnet") %> <% end %> + +<% elsif @tournament.players.include?(current_user) %> + <%= form_tag(tournament_path(@tournament), method: "put") do %> + + <%= submit_tag("Leave Tournamnet") %> + <% end %> <% end %> <%# If user is the host, let them start the tournment %> <% if @tournament.hosts.include?(current_user) %> + <%= form_tag(tournaments_path.to_s + "/" + @tournament.id.to_s + "/edit", method: "get") do %> <% if @tournament.players.count >= @tournament.min_players_per_team * @tournament.min_teams_per_match %> @@ -83,9 +90,12 @@ <%= submit_tag("Start Tournament", disabled: true) %> <% end %>
- <%= link_to 'Edit', edit_tournament_path(@tournament) %> | - <%= link_to 'Back', tournaments_path %> -<% end %> + <%= link_to 'Edit', edit_tournament_path(@tournament) %> | + <%= link_to 'Back', tournaments_path %> | + <%= link_to 'Cancel Tournament', @tournament, method: :delete, data: { confirm: 'Are you sure?' } %> + <% end %> + + <%end %> -- cgit v1.2.3