fix(clone-rescue): when record was invalid

This commit is contained in:
Colin Darie 2022-12-05 18:14:31 +01:00
parent 018f144e81
commit a2e80cfcca

View file

@ -333,8 +333,8 @@ module Users
cloned_dossier = @dossier.clone cloned_dossier = @dossier.clone
flash.notice = t('users.dossiers.cloned_success') flash.notice = t('users.dossiers.cloned_success')
redirect_to brouillon_dossier_path(cloned_dossier) redirect_to brouillon_dossier_path(cloned_dossier)
rescue ActiveRecord::ActiveRecordError => e rescue ActiveRecord::RecordInvalid => e
flash.alert = e.errors.full_messages flash.alert = e.record.errors.full_messages
redirect_to dossier_path(@dossier) redirect_to dossier_path(@dossier)
end end