From 685e834bb96fa0c3aea77aed48770b8577d74c7e Mon Sep 17 00:00:00 2001 From: Xinhui Date: Wed, 20 Dec 2017 14:24:02 +0100 Subject: Fix referential create redirect when invalid Refs #5297 --- app/controllers/referentials_controller.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 40e8264ce..9dbd659da 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -13,14 +13,16 @@ class ReferentialsController < ChouetteController end def create - create! do |format| + create! do |success, failure| build_referenial - if !!@referential.created_from_id - flash[:notice] = t('notice.referentials.duplicate') - - format.html { redirect_to workbench_path(@referential.workbench) } + success.html do + if @referential.created_from_id.present? + flash[:notice] = t('notice.referentials.duplicate') + redirect_to workbench_path(@referential.workbench) + end end + failure.html { render :new } end end -- cgit v1.2.3