From 2dd9a9af2f0033be8fb627e2113710505874008b Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 4 Jul 2017 01:28:55 +0900 Subject: Fix variables_controller.rb and format --- app/controllers/projects/variables_controller.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'app/controllers/projects') diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb index 716e1347604..dbd1e506002 100644 --- a/app/controllers/projects/variables_controller.rb +++ b/app/controllers/projects/variables_controller.rb @@ -13,18 +13,21 @@ class Projects::VariablesController < Projects::ApplicationController def update if @variable.update(project_params) - redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Variable was successfully updated.' + redirect_to namespace_project_variables_path(project.namespace, project), + notice: 'Variable was successfully updated.' else render "show" end end def create - @variable = Ci::Variable.new(project_params) + new_variable = Ci::Variable.new(project_params) - if @variable.valid? && @project.variables << @variable - redirect_to namespace_project_settings_ci_cd_path(project.namespace, project), notice: 'Variables were successfully updated.' + if new_variable.valid? && @project.variables << new_variable + redirect_to namespace_project_settings_ci_cd_path(project.namespace, project), + notice: 'Variables were successfully updated.' else + @variable = new_variable.present(current_user: current_user) render "show" end end @@ -40,8 +43,7 @@ class Projects::VariablesController < Projects::ApplicationController private def project_params - params.require(:variable) - .permit([:id, :key, :value, :protected, :_destroy]) + params.require(:variable).permit([:id, :key, :value, :protected, :_destroy]) end def variable -- cgit v1.2.3