change create avis concern

This commit is contained in:
kara Diaby 2021-04-01 11:58:02 +02:00
parent 60c06b6d8c
commit 436f567067

View file

@ -9,7 +9,8 @@ module CreateAvisConcern
# the :emails parameter is a 1-element array. # the :emails parameter is a 1-element array.
# Hence the call to first # Hence the call to first
# https://github.com/rails/rails/issues/17225 # https://github.com/rails/rails/issues/17225
expert_emails = create_avis_params[:emails].first.split(',').map(&:strip) expert_emails = create_avis_params[:emails].presence || [].to_json
expert_emails = JSON.parse(expert_emails).map(&:strip).map(&:downcase)
allowed_dossiers = [dossier] allowed_dossiers = [dossier]
if create_avis_params[:invite_linked_dossiers].present? if create_avis_params[:invite_linked_dossiers].present?
@ -65,6 +66,6 @@ module CreateAvisConcern
end end
def create_avis_params def create_avis_params
params.require(:avis).permit(:introduction_file, :introduction, :confidentiel, :invite_linked_dossiers, emails: []) params.require(:avis).permit(:introduction_file, :introduction, :confidentiel, :invite_linked_dossiers, :emails)
end end
end end