Fix JSON.parse crashing on empty values

This commit is contained in:
Paul Chavard 2021-03-03 17:31:05 +01:00
parent e2063e0fc8
commit e7ba380d95
2 changed files with 4 additions and 2 deletions

View file

@ -72,7 +72,8 @@ module Instructeurs
end end
def send_to_instructeurs def send_to_instructeurs
recipients = Instructeur.find(JSON.parse(params[:recipients])) recipients = params['recipients'].presence || [].to_json
recipients = Instructeur.find(JSON.parse(recipients))
recipients.each do |recipient| recipients.each do |recipient|
recipient.follow(dossier) recipient.follow(dossier)

View file

@ -138,7 +138,8 @@ module Instructeurs
end end
def update_displayed_fields def update_displayed_fields
procedure_presentation.update_displayed_fields(JSON.parse(params[:values])) values = params['values'].presence || [].to_json
procedure_presentation.update_displayed_fields(JSON.parse(values))
redirect_back(fallback_location: instructeur_procedure_url(procedure)) redirect_back(fallback_location: instructeur_procedure_url(procedure))
end end