Refactor message attachements to use active_storage

This commit is contained in:
Paul Chavard 2019-06-25 17:12:44 +02:00
parent 85f7412fa6
commit 3cb39c2840
20 changed files with 59 additions and 66 deletions

View file

@ -13,6 +13,11 @@ class CommentaireService
def build_with_email(email, dossier, params)
attributes = params.merge(email: email, dossier: dossier)
# For some reason ActiveStorage trows an error in tests if we passe an empty string here.
# I suspect it could be resolved in rails 6 by using explicit `attach()`
if attributes[:piece_jointe].blank?
attributes.delete(:piece_jointe)
end
Commentaire.new(attributes)
end
end