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

eager load weight and school

This commit is contained in:
2015-10-19 19:45:14 -04:00
parent 5d9398be16
commit 2df576e93c

View File

@@ -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