diff --git a/app/models/concerns/has_custom_fields.rb b/app/models/concerns/has_custom_fields.rb index c9910bf0b48..1e1f3869a10 100644 --- a/app/models/concerns/has_custom_fields.rb +++ b/app/models/concerns/has_custom_fields.rb @@ -91,7 +91,9 @@ module HasCustomFields fk = (name.underscore << "_id") - "#{name}CustomField".constantize.where("#{fk} in (?)", map.keys) + "#{name}CustomField".constantize + .where("#{fk} in (?)", map.keys) + .where("name in (?)", fields) .pluck(fk, :name, :value).each do |id, name, value| preloaded = map[id].preloaded_custom_fields