From c0ab1cc56ccd9893f3d50fc367e6c31edd9ecee7 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 20 Jan 2016 19:58:52 +0000 Subject: [PATCH] Remove caching for school show view and eager load correctly Could not do the caching properly with action buttons having permissions associated. The caching method was being called for every wrestler and took 150ms --- app/controllers/schools_controller.rb | 2 +- app/views/schools/show.html.erb | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index dce74bc..b651c99 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -69,7 +69,7 @@ class SchoolsController < ApplicationController private # Use callbacks to share common setup or constraints between actions. def set_school - @school = School.where(:id => params[:id]).includes(:tournament,:wrestlers,:deductedPoints).first + @school = School.where(:id => params[:id]).includes(:tournament,:wrestlers,:deductedPoints,:delegates).first end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/views/schools/show.html.erb b/app/views/schools/show.html.erb index 58fe6d3..dacc026 100644 --- a/app/views/schools/show.html.erb +++ b/app/views/schools/show.html.erb @@ -51,7 +51,6 @@ <% @wrestlers.sort_by{|w| w.weight.max}.each do |wrestler| %> - <% cache ["schools_view_wrestler", wrestler] do %> <%= wrestler.name %> <%= wrestler.weight.max %> @@ -63,7 +62,6 @@ Yes <% end %> <%= wrestler.nextMatchBoutNumber %> <%= wrestler.nextMatchMatName %> - <% end %> <%= link_to 'Show', wrestler , :class=>"btn btn-default btn-sm" %> <% if can? :manage, wrestler.school %>