diff --git a/app/models/type/attributes.rb b/app/models/type/attributes.rb index e9e14b85d172..f8383f7d533f 100644 --- a/app/models/type/attributes.rb +++ b/app/models/type/attributes.rb @@ -211,9 +211,14 @@ def active_custom_field_attributes ## # Returns whether the custom field is active in the given project. def custom_field_in_project?(attribute, project) - project - .all_work_package_custom_fields.pluck(:id) - .map { |id| "custom_field_#{id}" } + custom_fields_in_project = RequestStore.fetch(:"custom_field_in_project_#{project.id}") do + project + .all_work_package_custom_fields + .pluck(:id) + .map { |id| "custom_field_#{id}" } + end + + custom_fields_in_project .include? attribute end end