Skip to content

Commit

Permalink
Inline UserUpdate#call into Users::NamesController
Browse files Browse the repository at this point in the history
Only including the few bits we need.

We were hardly using any of the logic in `UserUpdate#call` and so I
think it's simpler and more idiomatic to include the logic directly in
the controller action.

In general I think there are better ways to avoid the kind of
duplication that `UserUpdate` was intended to avoid.
  • Loading branch information
floehopper committed Nov 8, 2023
1 parent 09ff60d commit 93fdf82
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/users/names_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class Users::NamesController < ApplicationController
def edit; end

def update
updater = UserUpdate.new(@user, user_params, current_user, user_ip_address)
if updater.call
if @user.update(user_params)
EventLog.record_event(@user, EventLog::ACCOUNT_UPDATED, initiator: current_user, ip_address: user_ip_address)
redirect_to user_path(@user), notice: "Updated user #{@user.email} successfully"
else
render :edit
Expand Down

0 comments on commit 93fdf82

Please sign in to comment.