summaryrefslogtreecommitdiff
path: root/app/controllers/tournaments_controller.rb
diff options
context:
space:
mode:
authorTomer Kimia <tkimia@purdue.edu>2014-04-01 17:14:05 -0400
committerTomer Kimia <tkimia@purdue.edu>2014-04-01 17:14:05 -0400
commit0867bc68749873aa131c0f3b273771b5f70ae778 (patch)
treed29a091054b4ac659af77072f55be1e7b1bf69cf /app/controllers/tournaments_controller.rb
parentcd6b94cfc989800d65acc0fbceeebe35da5be4af (diff)
players can now leave tournaments
Diffstat (limited to 'app/controllers/tournaments_controller.rb')
-rw-r--r--app/controllers/tournaments_controller.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 8d90758..2f04e1f 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -76,7 +76,16 @@ class TournamentsController < ApplicationController
end
format.html { render action: 'permission_denied', status: :forbidden }
format.json { render json: "Permission denied", status: :forbidden }
- end
+ end
+ when "leave"
+ respond_to do |format|
+ if @tournament.leave(current_user)
+ format.html {redirect_to tournaments_url, notice: 'You have left the tournament.' }
+ format.json { head :no_content }
+ end
+ format.html {redirect_to @tournament, notice: 'You were\'t a part of this tournament.' }
+ format.json { render json: "Permission denied", status: :forbidden }
+ end
when "open"
respond_to do |format|
if @tournament.setup