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
|
@ -166,8 +166,13 @@ class Admin::ProceduresController < AdminController
|
|||
flash.notice = 'Procédure clonée'
|
||||
redirect_to edit_admin_procedure_path(id: new_procedure.id)
|
||||
else
|
||||
flash.now.alert = new_procedure.errors.full_messages
|
||||
render 'index'
|
||||
if params[:from_new_from_existing].present?
|
||||
flash.alert = new_procedure.errors.full_messages
|
||||
redirect_to new_from_existing_admin_procedures_path
|
||||
else
|
||||
flash.now.alert = new_procedure.errors.full_messages
|
||||
render 'index'
|
||||
end
|
||||
end
|
||||
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
|
|
@ -18,4 +18,4 @@
|
|||
- if !procedure.archivee?
|
||||
= link_to('Tester', commencer_path(procedure_path: procedure.path), target: "_blank")
|
||||
%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