Commit e255e4de authored by Shinya Maeda's avatar Shinya Maeda

ayufan nice catches

parent 2dd9a9af
......@@ -20,9 +20,9 @@ module Groups
end
def create
new_variable = Ci::GroupVariable.new(group_params)
new_variable = group.variables.create(group_params)
if new_variable.valid? && group.variables << new_variable
if new_variable.persisted?
redirect_to group_settings_ci_cd_path(group),
notice: 'Variables were successfully updated.'
else
......@@ -32,11 +32,15 @@ module Groups
end
def destroy
variable.destroy
redirect_to group_settings_ci_cd_path(group),
status: 302,
notice: 'Variable was successfully removed.'
if variable.destroy
redirect_to group_settings_ci_cd_path(group),
status: 302,
notice: 'Variable was successfully removed.'
else
redirect_to group_settings_ci_cd_path(group),
status: 302,
notice: 'Failed to remove the variable'
end
end
private
......
......@@ -21,9 +21,9 @@ class Projects::VariablesController < Projects::ApplicationController
end
def create
new_variable = Ci::Variable.new(project_params)
new_variable = project.variables.create(project_params)
if new_variable.valid? && @project.variables << new_variable
if new_variable.persisted?
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project),
notice: 'Variables were successfully updated.'
else
......@@ -33,11 +33,15 @@ class Projects::VariablesController < Projects::ApplicationController
end
def destroy
variable.destroy
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project),
status: 302,
notice: 'Variable was successfully removed.'
if variable.destroy
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project),
status: 302,
notice: 'Variable was successfully removed.'
else
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project),
status: 302,
notice: 'Failed to remove the variable'
end
end
private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment