1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-03 13:30:02 +00:00

Test protecting controller paths

This commit is contained in:
2015-10-30 07:51:35 -04:00
parent d1437a56af
commit 685c71ade9
9 changed files with 457 additions and 52 deletions

View File

@@ -80,12 +80,15 @@ class SchoolsController < ApplicationController
def check_access
if params[:tournament]
@tournament = params[:tournament]
else
@tournament = Tournament.find(params[:tournament])
elsif params[:school]
@school = School.new(school_params)
@tournament = Tournament.find(@school.tournament_id)
elsif @school
@tournament = @school.tournament
end
if current_user != @tournament.user
redirect_to root_path
redirect_to '/static_pages/not_allowed'
end
end