From 42ed6d7c87e7cb181d893621c69b517f000d5cb7 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 16 Jul 2024 09:03:56 +0200 Subject: [PATCH] refactor(dossier): use each instead of filter with side effects --- app/models/dossier.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index f070ccff1..1f175d858 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -936,7 +936,12 @@ class Dossier < ApplicationRecord end def remove_piece_justificative_file_not_visible! - champs.filter { _1.piece_justificative_file.attached? && !_1.visible? && _1.piece_justificative_file.purge_later } + champs.each do |champ| + next unless champ.piece_justificative_file.attached? + next if champ.visible? + + champ.piece_justificative_file.purge_later + end end def check_mandatory_and_visible_champs