From 8e1319f54e143011ec1f5e7eefa3b6aa87c26cd6 Mon Sep 17 00:00:00 2001
From: Go MAEDA
Date: Wed, 27 Dec 2023 09:31:20 +0000
Subject: [PATCH] Optimize IssueCategory SQL queries when showing an issue
(#39849).
Patch by Go MAEDA.
git-svn-id: https://svn.redmine.org/redmine/trunk@22568 e93f8b46-1217-0410-a6f0-8f06a7374b81
---
app/views/issues/_attributes.html.erb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/issues/_attributes.html.erb b/app/views/issues/_attributes.html.erb
index 0487b5ee2..40b89547a 100644
--- a/app/views/issues/_attributes.html.erb
+++ b/app/views/issues/_attributes.html.erb
@@ -32,8 +32,8 @@
<% end %>
-<% if @issue.safe_attribute?('category_id') && @issue.project.issue_categories.any? %>
-<%= f.select :category_id, (@issue.project.issue_categories.collect {|c| [c.name, c.id]}),
+<% if @issue.safe_attribute?('category_id') && (category_options = @issue.project.issue_categories.pluck(:name, :id)).present? %>
+
<%= f.select :category_id, category_options,
{:include_blank => true, :required => @issue.required_attribute?('category_id')},
:onchange => ("updateIssueFrom('#{escape_javascript(update_issue_form_path(@project, @issue))}', this)" if @issue.new_record?) %>
<%= link_to(l(:label_issue_category_new),