Skip to content

Commit

Permalink
Replace update+save with a single update call
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonMatthes committed Mar 1, 2019
1 parent 6f80fb6 commit e3f8664
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions app/controllers/vms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def update
notify_changed_users(@vm.users.map(&:id), info_params[:non_sudo_user_ids].map(&:to_i), false, @vm.name)
@vm.sudo_users = info_params[:sudo_user_ids]
@vm.users = info_params[:non_sudo_user_ids]
@vm.ensure_config.update config_params
unless @vm.config.save

unless @vm.ensure_config.update config_params
flash[:error] = 'Description couldn\'t be saved.'
redirect_to edit_vm_path(@vm.name)
end
Expand Down Expand Up @@ -153,10 +153,6 @@ def reset_vm
redirect_back(fallback_location: root_path)
end

# This controller doesn't use strong parameters
# https://edgeapi.rubyonrails.org/classes/ActionController/StrongParameters.html
# Because no Active Record model is being wrapped

private

def prepare_info_params
Expand Down

0 comments on commit e3f8664

Please sign in to comment.