diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb
index 2ebd8ccee7055184c8681e95ae6e2223f479b96b..a4d1b1ee69b7d85c03de0bc90bdaf63333c9cb2f 100644
--- a/app/controllers/projects/variables_controller.rb
+++ b/app/controllers/projects/variables_controller.rb
@@ -26,10 +26,10 @@ class Projects::VariablesController < Projects::ApplicationController
 
     if @variable.valid? && @project.variables << @variable
       flash[:notice] = 'Variables were successfully updated.'
+      redirect_to namespace_project_settings_ci_cd_path(project.namespace, project)
     else
-      flash[:alert] = @variable.errors.full_messages.join(',').html_safe
+      render "show"
     end
-    redirect_to namespace_project_settings_ci_cd_path(project.namespace, project)
   end
 
   def destroy