From 3e9aeea75d7fec0f312726d890212262eaf940fa Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 11 Jun 2013 17:24:17 +0000 Subject: [PATCH] Perf: preload a few associations for bulk operations. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11957 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a3fbae5aa..7f42fff76 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -298,7 +298,7 @@ class ApplicationController < ActionController::Base # Find issues with a single :id param or :ids array param # Raises a Unauthorized exception if one of the issues is not visible def find_issues - @issues = Issue.find_all_by_id(params[:id] || params[:ids]) + @issues = Issue.where(:id => (params[:id] || params[:ids])).preload(:project, :status, :tracker, :priority, :author, :assigned_to, :relations_to).to_a raise ActiveRecord::RecordNotFound if @issues.empty? raise Unauthorized unless @issues.all?(&:visible?) @projects = @issues.collect(&:project).compact.uniq