summaryrefslogtreecommitdiff
path: root/app/controllers/projects/variables_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/projects/variables_controller.rb')
-rw-r--r--app/controllers/projects/variables_controller.rb23
1 files changed, 13 insertions, 10 deletions
diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb
index 50e25a00f03..326d31ecec2 100644
--- a/app/controllers/projects/variables_controller.rb
+++ b/app/controllers/projects/variables_controller.rb
@@ -4,7 +4,7 @@ class Projects::VariablesController < Projects::ApplicationController
layout 'project_settings'
def index
- redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
+ redirect_to project_settings_ci_cd_path(@project)
end
def show
@@ -14,19 +14,19 @@ class Projects::VariablesController < Projects::ApplicationController
def update
@variable = @project.variables.find(params[:id])
- if @variable.update_attributes(project_params)
- redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Variable was successfully updated.'
+ if @variable.update_attributes(variable_params)
+ redirect_to project_variables_path(project), notice: 'Variable was successfully updated.'
else
render action: "show"
end
end
def create
- @variable = Ci::Variable.new(project_params)
+ @variable = @project.variables.new(variable_params)
- if @variable.valid? && @project.variables << @variable
+ if @variable.save
flash[:notice] = 'Variables were successfully updated.'
- redirect_to namespace_project_settings_ci_cd_path(project.namespace, project)
+ redirect_to project_settings_ci_cd_path(project)
else
render "show"
end
@@ -36,15 +36,18 @@ class Projects::VariablesController < Projects::ApplicationController
@key = @project.variables.find(params[:id])
@key.destroy
- redirect_to namespace_project_settings_ci_cd_path(project.namespace, project),
+ redirect_to project_settings_ci_cd_path(project),
status: 302,
notice: 'Variable was successfully removed.'
end
private
- def project_params
- params.require(:variable)
- .permit([:id, :key, :value, :protected, :_destroy])
+ def variable_params
+ params.require(:variable).permit(*variable_params_attributes)
+ end
+
+ def variable_params_attributes
+ %i[id key value protected _destroy]
end
end