mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-11 16:01:56 +00:00
Fixed check_access bug
This commit is contained in:
@@ -47,8 +47,8 @@ class MatchesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check_access
|
def check_access
|
||||||
if current_user != @match.tournament.user
|
if current_user != @match.tournament.user
|
||||||
redirect_to '/static_pages/not_allowed'
|
redirect_to '/static_pages/not_allowed'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -80,8 +80,7 @@ class SchoolsController < ApplicationController
|
|||||||
if params[:tournament]
|
if params[:tournament]
|
||||||
@tournament = Tournament.find(params[:tournament])
|
@tournament = Tournament.find(params[:tournament])
|
||||||
elsif params[:school]
|
elsif params[:school]
|
||||||
@school = School.new(school_params)
|
@tournament = Tournament.find(params[:school]["tournament_id"])
|
||||||
@tournament = Tournament.find(@school.tournament_id)
|
|
||||||
elsif @school
|
elsif @school
|
||||||
@tournament = @school.tournament
|
@tournament = @school.tournament
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -87,8 +87,7 @@ class WeightsController < ApplicationController
|
|||||||
if params[:tournament]
|
if params[:tournament]
|
||||||
@tournament = Tournament.find(params[:tournament])
|
@tournament = Tournament.find(params[:tournament])
|
||||||
elsif params[:weight]
|
elsif params[:weight]
|
||||||
@weight = Weight.new(weight_params)
|
@tournament = Tournament.find(params[:weight]["tournament_id"])
|
||||||
@tournament = Tournament.find(@weight.tournament_id)
|
|
||||||
elsif @weight
|
elsif @weight
|
||||||
@tournament = @weight.tournament
|
@tournament = @weight.tournament
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class WrestlersController < ApplicationController
|
|||||||
private
|
private
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_wrestler
|
def set_wrestler
|
||||||
@wrestler = Wrestler.find(params[:id])
|
@wrestler = Wrestler.where(:id => params[:id]).includes(:school, :weight, :tournament, :matches).first
|
||||||
end
|
end
|
||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
@@ -94,8 +94,7 @@ class WrestlersController < ApplicationController
|
|||||||
@school = School.find(params[:school])
|
@school = School.find(params[:school])
|
||||||
@tournament = Tournament.find(@school.tournament.id)
|
@tournament = Tournament.find(@school.tournament.id)
|
||||||
elsif params[:wrestler]
|
elsif params[:wrestler]
|
||||||
@wrestler = Wrestler.new(wrestler_params)
|
@school = School.find(params[:wrestler]["school_id"])
|
||||||
@school = School.find(@wrestler.school_id)
|
|
||||||
@tournament = Tournament.find(@school.tournament.id)
|
@tournament = Tournament.find(@school.tournament.id)
|
||||||
elsif @wrestler
|
elsif @wrestler
|
||||||
@tournament = @wrestler.tournament
|
@tournament = @wrestler.tournament
|
||||||
|
|||||||
Reference in New Issue
Block a user