Commit e255e4de authored by Shinya Maeda's avatar Shinya Maeda

ayufan nice catches

parent 2dd9a9af
...@@ -20,9 +20,9 @@ module Groups ...@@ -20,9 +20,9 @@ module Groups
end end
def create 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), redirect_to group_settings_ci_cd_path(group),
notice: 'Variables were successfully updated.' notice: 'Variables were successfully updated.'
else else
...@@ -32,11 +32,15 @@ module Groups ...@@ -32,11 +32,15 @@ module Groups
end end
def destroy def destroy
variable.destroy if variable.destroy
redirect_to group_settings_ci_cd_path(group),
redirect_to group_settings_ci_cd_path(group), status: 302,
status: 302, notice: 'Variable was successfully removed.'
notice: 'Variable was successfully removed.' else
redirect_to group_settings_ci_cd_path(group),
status: 302,
notice: 'Failed to remove the variable'
end
end end
private private
......
...@@ -21,9 +21,9 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -21,9 +21,9 @@ class Projects::VariablesController < Projects::ApplicationController
end end
def create 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), redirect_to namespace_project_settings_ci_cd_path(project.namespace, project),
notice: 'Variables were successfully updated.' notice: 'Variables were successfully updated.'
else else
...@@ -33,11 +33,15 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -33,11 +33,15 @@ class Projects::VariablesController < Projects::ApplicationController
end end
def destroy def destroy
variable.destroy if variable.destroy
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project),
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project), status: 302,
status: 302, notice: 'Variable was successfully removed.'
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 end
private 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