ayufan nice catches

This commit is contained in:
Shinya Maeda 2017-07-04 22:27:42 +09:00
parent 2dd9a9af2f
commit e255e4de69
2 changed files with 22 additions and 14 deletions

View File

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

View File

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