mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-06 06:28:33 +00:00
eager load weight and school
This commit is contained in:
@@ -41,7 +41,7 @@ class StaticPagesController < ApplicationController
|
|||||||
@weight = Weight.find(params[:weight])
|
@weight = Weight.find(params[:weight])
|
||||||
@tournament = Tournament.find(@weight.tournament_id)
|
@tournament = Tournament.find(@weight.tournament_id)
|
||||||
@matches = @tournament.matches.select{|m| m.weight_id == @weight.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?
|
if @matches.empty? or @wrestlers.empty?
|
||||||
redirect_to "/static_pages/noMatches?tournament=#{@tournament.id}"
|
redirect_to "/static_pages/noMatches?tournament=#{@tournament.id}"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user