Fix variables_controller.rb and format

This commit is contained in:
Shinya Maeda 2017-07-04 01:28:55 +09:00
parent d228662fb7
commit 2dd9a9af2f
2 changed files with 9 additions and 8 deletions

View File

@ -46,8 +46,7 @@ module Groups
end
def group_params
params.require(:variable)
.permit([:key, :value, :protected])
params.require(:variable).permit([:key, :value, :protected])
end
def variable

View File

@ -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