diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-03-06 18:55:38 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-03-06 18:55:38 -0500 |
commit | 1788dde36e53c4ef16adc5db2d19f44797325496 (patch) | |
tree | 4d331750a288fcdc052df2ae7dff19c68cd24151 /app/controllers/tournaments_controller.rb | |
parent | 39f373778e73c54952dddd11e87f4ba354471622 (diff) |
implement tournament joining
Diffstat (limited to 'app/controllers/tournaments_controller.rb')
-rw-r--r-- | app/controllers/tournaments_controller.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 915c072..5e79d7a 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -1,5 +1,5 @@ class TournamentsController < ApplicationController - before_action :set_tournament, only: [:show, :edit, :update, :destroy] + before_action :set_tournament, only: [:show, :edit, :update, :destroy, :join] before_action :check_perms, only: [:new, :create, :edit, :update, :destroy] # GET /tournaments @@ -64,6 +64,19 @@ class TournamentsController < ApplicationController end end + # POST /tournaments/1/join + # POST /tournaments/1/join.json + def join + respond_to do |format| + if @tournament.join(current_user) + format.html { redirect_to @tournament, notice: 'You have joined this tournament.' } + format.json { head :no_content } + end + format.html { render action: 'permission_denied', status: :forbidden } + format.json { render json: "Permission denied", status: :forbidden } + end + end + private # Use callbacks to share common setup or constraints between actions. def set_tournament |