Correctly handle errors when cloning someone else’s procedure
This commit is contained in:
parent
a1275af55f
commit
c77558aeed
2 changed files with 8 additions and 3 deletions
|
@ -165,10 +165,15 @@ class Admin::ProceduresController < AdminController
|
||||||
if new_procedure.save
|
if new_procedure.save
|
||||||
flash.notice = 'Procédure clonée'
|
flash.notice = 'Procédure clonée'
|
||||||
redirect_to edit_admin_procedure_path(id: new_procedure.id)
|
redirect_to edit_admin_procedure_path(id: new_procedure.id)
|
||||||
|
else
|
||||||
|
if params[:from_new_from_existing].present?
|
||||||
|
flash.alert = new_procedure.errors.full_messages
|
||||||
|
redirect_to new_from_existing_admin_procedures_path
|
||||||
else
|
else
|
||||||
flash.now.alert = new_procedure.errors.full_messages
|
flash.now.alert = new_procedure.errors.full_messages
|
||||||
render 'index'
|
render 'index'
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
flash.alert = 'Procédure inexistante'
|
flash.alert = 'Procédure inexistante'
|
||||||
|
|
|
@ -18,4 +18,4 @@
|
||||||
- if !procedure.archivee?
|
- if !procedure.archivee?
|
||||||
= link_to('Tester', commencer_path(procedure_path: procedure.path), target: "_blank")
|
= link_to('Tester', commencer_path(procedure_path: procedure.path), target: "_blank")
|
||||||
%td
|
%td
|
||||||
= link_to('Cloner', admin_procedure_clone_path(procedure.id), 'data-method' => :put, class: 'btn-sm btn-primary clone-btn')
|
= link_to('Cloner', admin_procedure_clone_path(procedure.id, from_new_from_existing: true), 'data-method' => :put, class: 'btn-sm btn-primary clone-btn')
|
||||||
|
|
Loading…
Reference in a new issue