dossiers: rescue RecordNotFound only for procedures
This ensures that we won't rescue an `ActiveRecord::RecordNotFound` exception related to another object.
This commit is contained in:
parent
7f5b0d8bf3
commit
5b2311c851
1 changed files with 9 additions and 8 deletions
|
@ -220,10 +220,15 @@ module Users
|
||||||
def new
|
def new
|
||||||
erase_user_location!
|
erase_user_location!
|
||||||
|
|
||||||
if params[:brouillon]
|
begin
|
||||||
procedure = Procedure.brouillon.find(params[:procedure_id])
|
if params[:brouillon]
|
||||||
else
|
procedure = Procedure.brouillon.find(params[:procedure_id])
|
||||||
procedure = Procedure.publiees.find(params[:procedure_id])
|
else
|
||||||
|
procedure = Procedure.publiees.find(params[:procedure_id])
|
||||||
|
end
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
flash.alert = t('errors.messages.procedure_not_found')
|
||||||
|
return redirect_to url_for dossiers_path
|
||||||
end
|
end
|
||||||
|
|
||||||
dossier = Dossier.create!(groupe_instructeur: procedure.defaut_groupe_instructeur, user: current_user, state: Dossier.states.fetch(:brouillon))
|
dossier = Dossier.create!(groupe_instructeur: procedure.defaut_groupe_instructeur, user: current_user, state: Dossier.states.fetch(:brouillon))
|
||||||
|
@ -237,10 +242,6 @@ module Users
|
||||||
else
|
else
|
||||||
redirect_to siret_dossier_path(id: dossier.id)
|
redirect_to siret_dossier_path(id: dossier.id)
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
|
||||||
flash.alert = t('errors.messages.procedure_not_found')
|
|
||||||
|
|
||||||
redirect_to url_for dossiers_path
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def dossier_for_help
|
def dossier_for_help
|
||||||
|
|
Loading…
Add table
Reference in a new issue