diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index ffebf35..3869ef6 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, Tournament.where(:id => @match.tournament.id).includes(:delegates,:user).first + authorize! :manage, @match.tournament end end diff --git a/app/controllers/mats_controller.rb b/app/controllers/mats_controller.rb index 6d139d1..6b517c9 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.where(:id => params[:tournament]).includes(:delegates,:user).first + @tournament = Tournament.find(params[:tournament]) elsif params[:mat] @mat = Mat.new(mat_params) - @tournament = Tournament.where(:id => @mat.tournament_id).includes(:delegates,:user).first + @tournament = Tournament.find(@mat.tournament_id) elsif @mat - @tournament = Tournament.where(:id => @mat.tournament.id).includes(:delegates,:user).first + @tournament = @mat.tournament end authorize! :manage, @tournament end diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index 510dda2..b651c99 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.where(:id => params[:tournament]).includes(:delegates,:user).first + @tournament = Tournament.find(params[:tournament]) elsif params[:school] - @tournament = Tournament.where(:id => params[:school]["tournament_id"]).includes(:delegates,:user).first + @tournament = Tournament.find(params[:school]["tournament_id"]) elsif @school - @tournament = Tournament.where(:id => @school.tournament.id).includes(:delegates,:user).first + @tournament = @school.tournament elsif school_params - @tournament = Tournament.where(:id => school_params[:tournament_id]).includes(:delegates,:user).first + @tournament = Tournament.find(school_params[:tournament_id]) end authorize! :manage, @tournament end diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 8d87bda..48e8425 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -241,7 +241,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,:delegates).first + @tournament = Tournament.where(:id => params[:id]).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).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 0dfa582..54bc317 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.where(:id => params[:tournament]).includes(:delegates,:user).first + @tournament = Tournament.find(params[:tournament]) elsif params[:weight] - @tournament = Tournament.where(:id => params[:weight]["tournament_id"]).includes(:delegates,:user).first + @tournament = Tournament.find(params[:weight]["tournament_id"]) elsif @weight - @tournament = Tournament.where(:id => @weight.tournament.id).includes(:delegates,:user).first + @tournament = @weight.tournament end authorize! :manage, @tournament end diff --git a/app/controllers/wrestlers_controller.rb b/app/controllers/wrestlers_controller.rb index bf67bd2..ae055f5 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.where(:id => params[:school]).includes(:delegates,:tournament).first + @school = School.find(params[:school]) #@tournament = Tournament.find(@school.tournament.id) elsif params[:wrestler] - @school = School.where(:id => params[:wrestler]["school_id"]).includes(:delegates,:tournament).first + @school = School.find(params[:wrestler]["school_id"]) #@tournament = Tournament.find(@school.tournament.id) elsif @wrestler - @school = School.where(:id => @wrestler.school.tournament.id).includes(:delegates,:tournament).first + @school = @wrestler.school #@tournament = @wrestler.tournament elsif wrestler_params - @school = School.where(:id => wrestler_params[:school_id]).includes(:delegates,:tournament).first + @school = School.find(wrestler_params[:school_id]) end authorize! :manage, @school end