From 2df576e93c8b6f7c8bcd64da8b3b9654341e3dd3 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Mon, 19 Oct 2015 19:45:14 -0400 Subject: [PATCH] eager load weight and school --- app/controllers/static_pages_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 9da4c86..3397830 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -41,7 +41,7 @@ class StaticPagesController < ApplicationController @weight = Weight.find(params[:weight]) @tournament = Tournament.find(@weight.tournament_id) @matches = @tournament.matches.select{|m| m.weight_id == @weight.id} - @wrestlers = Wrestler.where(weight_id: @weight.id) + @wrestlers = Wrestler.where(weight_id: @weight.id).includes(:weight,:school) if @matches.empty? or @wrestlers.empty? redirect_to "/static_pages/noMatches?tournament=#{@tournament.id}" else