diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 3869ef6..ffebf35 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -49,6 +49,6 @@ class MatchesController < ApplicationController end def check_access - authorize! :manage, @match.tournament + authorize! :manage, Tournament.where(:id => @match.tournament.id).includes(:delegates,:user).first end end diff --git a/app/controllers/mats_controller.rb b/app/controllers/mats_controller.rb index 6b517c9..6d139d1 100644 --- a/app/controllers/mats_controller.rb +++ b/app/controllers/mats_controller.rb @@ -82,12 +82,12 @@ class MatsController < ApplicationController def check_access if params[:tournament] - @tournament = Tournament.find(params[:tournament]) + @tournament = Tournament.where(:id => params[:tournament]).includes(:delegates,:user).first elsif params[:mat] @mat = Mat.new(mat_params) - @tournament = Tournament.find(@mat.tournament_id) + @tournament = Tournament.where(:id => @mat.tournament_id).includes(:delegates,:user).first elsif @mat - @tournament = @mat.tournament + @tournament = Tournament.where(:id => @mat.tournament.id).includes(:delegates,:user).first end authorize! :manage, @tournament end diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index b651c99..510dda2 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -79,13 +79,13 @@ class SchoolsController < ApplicationController def check_access_director if params[:tournament] - @tournament = Tournament.find(params[:tournament]) + @tournament = Tournament.where(:id => params[:tournament]).includes(:delegates,:user).first elsif params[:school] - @tournament = Tournament.find(params[:school]["tournament_id"]) + @tournament = Tournament.where(:id => params[:school]["tournament_id"]).includes(:delegates,:user).first elsif @school - @tournament = @school.tournament + @tournament = Tournament.where(:id => @school.tournament.id).includes(:delegates,:user).first elsif school_params - @tournament = Tournament.find(school_params[:tournament_id]) + @tournament = Tournament.where(:id => school_params[:tournament_id]).includes(:delegates,:user).first end authorize! :manage, @tournament end diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 77d1ef4..b626a14 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -236,7 +236,7 @@ class TournamentsController < ApplicationController private # Use callbacks to share common setup or constraints between actions. def set_tournament - @tournament = Tournament.where(:id => params[:id]).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).first + @tournament = Tournament.where(:id => params[:id]).includes(:schools,:weights,:mats,:matches,:user,:wrestlers,:delegates).first end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/controllers/weights_controller.rb b/app/controllers/weights_controller.rb index 54bc317..0dfa582 100644 --- a/app/controllers/weights_controller.rb +++ b/app/controllers/weights_controller.rb @@ -82,11 +82,11 @@ class WeightsController < ApplicationController end def check_access if params[:tournament] - @tournament = Tournament.find(params[:tournament]) + @tournament = Tournament.where(:id => params[:tournament]).includes(:delegates,:user).first elsif params[:weight] - @tournament = Tournament.find(params[:weight]["tournament_id"]) + @tournament = Tournament.where(:id => params[:weight]["tournament_id"]).includes(:delegates,:user).first elsif @weight - @tournament = @weight.tournament + @tournament = Tournament.where(:id => @weight.tournament.id).includes(:delegates,:user).first end authorize! :manage, @tournament end diff --git a/app/controllers/wrestlers_controller.rb b/app/controllers/wrestlers_controller.rb index ae055f5..bf67bd2 100644 --- a/app/controllers/wrestlers_controller.rb +++ b/app/controllers/wrestlers_controller.rb @@ -91,16 +91,16 @@ class WrestlersController < ApplicationController end def check_access if params[:school] - @school = School.find(params[:school]) + @school = School.where(:id => params[:school]).includes(:delegates,:tournament).first #@tournament = Tournament.find(@school.tournament.id) elsif params[:wrestler] - @school = School.find(params[:wrestler]["school_id"]) + @school = School.where(:id => params[:wrestler]["school_id"]).includes(:delegates,:tournament).first #@tournament = Tournament.find(@school.tournament.id) elsif @wrestler - @school = @wrestler.school + @school = School.where(:id => @wrestler.school.tournament.id).includes(:delegates,:tournament).first #@tournament = @wrestler.tournament elsif wrestler_params - @school = School.find(wrestler_params[:school_id]) + @school = School.where(:id => wrestler_params[:school_id]).includes(:delegates,:tournament).first end authorize! :manage, @school end