From fb07bdb8aab44cec5a0b59815493ebd19ed16ebd Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Fri, 18 Oct 2024 18:17:17 +0200 Subject: [PATCH] fix(dossier): fix preloader with champs outside of revision --- app/models/dossier_preloader.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/dossier_preloader.rb b/app/models/dossier_preloader.rb index c1f8d82fa..f1056a9ad 100644 --- a/app/models/dossier_preloader.rb +++ b/app/models/dossier_preloader.rb @@ -63,7 +63,8 @@ class DossierPreloader def load_etablissements(champs) to_include = @includes_for_etablissement.dup - champs_siret = champs.filter(&:siret?) + # `champs.siret?` will delegate to type_de_champ; this is not what we want here + champs_siret = champs.filter { _1.type == 'Champs::SiretChamp' } etablissements_by_id = Etablissement.includes(to_include).where(id: champs_siret.map(&:etablissement_id).compact).index_by(&:id) champs_siret.each do |champ| etablissement = etablissements_by_id[champ.etablissement_id]