From 1516d7ae14ba936cffb5904081d28f83ddec9d3c Mon Sep 17 00:00:00 2001 From: lukemelia Date: Tue, 27 Nov 2007 03:00:38 +0000 Subject: [PATCH] Learned a better way to force an immediate load of an association (passing (true)) and applied it to the index action of the contexts and projects controller. Thanks to teferi in @nyc.rb for the assist. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@661 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/contexts_controller.rb | 2 +- tracks/app/controllers/projects_controller.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tracks/app/controllers/contexts_controller.rb b/tracks/app/controllers/contexts_controller.rb index 8efcce47..08eab114 100644 --- a/tracks/app/controllers/contexts_controller.rb +++ b/tracks/app/controllers/contexts_controller.rb @@ -10,7 +10,7 @@ class ContextsController < ApplicationController session :off, :only => :index, :if => Proc.new { |req| ['rss','atom','txt'].include?(req.parameters[:format]) } def index - @contexts = current_user.contexts.reload #reload is called here to force an immediate load so that size and empty? checks later don't result in separate SQL queries + @contexts = current_user.contexts(true) #true is passed here to force an immediate load so that size and empty? checks later don't result in separate SQL queries init_not_done_counts(['context']) respond_to do |format| format.html &render_contexts_html diff --git a/tracks/app/controllers/projects_controller.rb b/tracks/app/controllers/projects_controller.rb index 6efdfb50..441ff225 100644 --- a/tracks/app/controllers/projects_controller.rb +++ b/tracks/app/controllers/projects_controller.rb @@ -9,8 +9,8 @@ class ProjectsController < ApplicationController session :off, :only => :index, :if => Proc.new { |req| ['rss','atom','txt'].include?(req.parameters[:format]) } def index - @projects = current_user.projects - @contexts = current_user.contexts + @projects = current_user.projects(true) + @contexts = current_user.contexts(true) init_not_done_counts(['project']) if params[:only_active_with_no_next_actions] @projects = @projects.select { |p| p.active? && count_undone_todos(p) == 0 }