diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-07-04 22:27:42 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-07-07 15:35:12 +0900 |
commit | e255e4de6943f419e4d1137104f990a120e3f72a (patch) | |
tree | 54dfe7aceb285b30c31d8470fe6cdd5f80fde354 /app/controllers/groups | |
parent | 2dd9a9af2f0033be8fb627e2113710505874008b (diff) | |
download | gitlab-ce-e255e4de6943f419e4d1137104f990a120e3f72a.tar.gz |
ayufan nice catches
Diffstat (limited to 'app/controllers/groups')
-rw-r--r-- | app/controllers/groups/variables_controller.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/app/controllers/groups/variables_controller.rb b/app/controllers/groups/variables_controller.rb index beafea7b451..ece2ba62e0a 100644 --- a/app/controllers/groups/variables_controller.rb +++ b/app/controllers/groups/variables_controller.rb @@ -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 |