diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-07-04 16:27:42 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-07-07 09:35:12 +0300 |
commit | e255e4de6943f419e4d1137104f990a120e3f72a (patch) | |
tree | 54dfe7aceb285b30c31d8470fe6cdd5f80fde354 /app/controllers/projects/variables_controller.rb | |
parent | 2dd9a9af2f0033be8fb627e2113710505874008b (diff) |
ayufan nice catches
Diffstat (limited to 'app/controllers/projects/variables_controller.rb')
-rw-r--r-- | app/controllers/projects/variables_controller.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb index dbd1e506002..176c0294ead 100644 --- a/app/controllers/projects/variables_controller.rb +++ b/app/controllers/projects/variables_controller.rb @@ -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 |