app/controllers/custom_fields_controller.rb | 2 ++ app/views/custom_fields/_index.html.erb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb index 1679846..a6d1268 100644 --- a/app/controllers/custom_fields_controller.rb +++ b/app/controllers/custom_fields_controller.rb @@ -27,6 +27,8 @@ class CustomFieldsController < ApplicationController respond_to do |format| format.html { @custom_fields_by_type = CustomField.all.group_by {|f| f.class.name } + @custom_fields_projects_count = + IssueCustomField.where(is_for_all: false).joins(:projects).group(:custom_field_id).count } format.api { @custom_fields = CustomField.all diff --git a/app/views/custom_fields/_index.html.erb b/app/views/custom_fields/_index.html.erb index 42efe35..ecff418 100644 --- a/app/views/custom_fields/_index.html.erb +++ b/app/views/custom_fields/_index.html.erb @@ -19,7 +19,7 @@ <%= checked_image custom_field.is_required? %> <% if tab[:name] == 'IssueCustomField' %> <%= checked_image custom_field.is_for_all? %> - <%= l(:label_x_projects, :count => custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %> + <%= l(:label_x_projects, :count => @custom_fields_projects_count[custom_field.id]) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %> <% end %> <%= call_hook :view_custom_fields_table_data, :tab => tab, :custom_field => custom_field %>