1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Revert "Eager load users and delegates for tournaments, eager load delegates and tournament for schools"

This reverts commit 911faceb7c.

Permissions to edit a wrestler are not working in production.
This commit is contained in:
2016-01-22 13:21:13 +00:00
parent 285cfa9647
commit e48d473807
6 changed files with 16 additions and 16 deletions

View File

@@ -49,6 +49,6 @@ class MatchesController < ApplicationController
end end
def check_access def check_access
authorize! :manage, Tournament.where(:id => @match.tournament.id).includes(:delegates,:user).first authorize! :manage, @match.tournament
end end
end end

View File

@@ -82,12 +82,12 @@ class MatsController < ApplicationController
def check_access def check_access
if params[:tournament] if params[:tournament]
@tournament = Tournament.where(:id => params[:tournament]).includes(:delegates,:user).first @tournament = Tournament.find(params[:tournament])
elsif params[:mat] elsif params[:mat]
@mat = Mat.new(mat_params) @mat = Mat.new(mat_params)
@tournament = Tournament.where(:id => @mat.tournament_id).includes(:delegates,:user).first @tournament = Tournament.find(@mat.tournament_id)
elsif @mat elsif @mat
@tournament = Tournament.where(:id => @mat.tournament.id).includes(:delegates,:user).first @tournament = @mat.tournament
end end
authorize! :manage, @tournament authorize! :manage, @tournament
end end

View File

@@ -79,13 +79,13 @@ class SchoolsController < ApplicationController
def check_access_director def check_access_director
if params[:tournament] if params[:tournament]
@tournament = Tournament.where(:id => params[:tournament]).includes(:delegates,:user).first @tournament = Tournament.find(params[:tournament])
elsif params[:school] elsif params[:school]
@tournament = Tournament.where(:id => params[:school]["tournament_id"]).includes(:delegates,:user).first @tournament = Tournament.find(params[:school]["tournament_id"])
elsif @school elsif @school
@tournament = Tournament.where(:id => @school.tournament.id).includes(:delegates,:user).first @tournament = @school.tournament
elsif school_params elsif school_params
@tournament = Tournament.where(:id => school_params[:tournament_id]).includes(:delegates,:user).first @tournament = Tournament.find(school_params[:tournament_id])
end end
authorize! :manage, @tournament authorize! :manage, @tournament
end end

View File

@@ -241,7 +241,7 @@ class TournamentsController < 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_tournament 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 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.

View File

@@ -82,11 +82,11 @@ class WeightsController < ApplicationController
end end
def check_access def check_access
if params[:tournament] if params[:tournament]
@tournament = Tournament.where(:id => params[:tournament]).includes(:delegates,:user).first @tournament = Tournament.find(params[:tournament])
elsif params[:weight] elsif params[:weight]
@tournament = Tournament.where(:id => params[:weight]["tournament_id"]).includes(:delegates,:user).first @tournament = Tournament.find(params[:weight]["tournament_id"])
elsif @weight elsif @weight
@tournament = Tournament.where(:id => @weight.tournament.id).includes(:delegates,:user).first @tournament = @weight.tournament
end end
authorize! :manage, @tournament authorize! :manage, @tournament
end end

View File

@@ -91,16 +91,16 @@ class WrestlersController < ApplicationController
end end
def check_access def check_access
if params[:school] if params[:school]
@school = School.where(:id => params[:school]).includes(:delegates,:tournament).first @school = School.find(params[:school])
#@tournament = Tournament.find(@school.tournament.id) #@tournament = Tournament.find(@school.tournament.id)
elsif params[:wrestler] 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) #@tournament = Tournament.find(@school.tournament.id)
elsif @wrestler elsif @wrestler
@school = School.where(:id => @wrestler.school.tournament.id).includes(:delegates,:tournament).first @school = @wrestler.school
#@tournament = @wrestler.tournament #@tournament = @wrestler.tournament
elsif wrestler_params elsif wrestler_params
@school = School.where(:id => wrestler_params[:school_id]).includes(:delegates,:tournament).first @school = School.find(wrestler_params[:school_id])
end end
authorize! :manage, @school authorize! :manage, @school
end end