Module: Account::Users::ControllerBase

Extended by:
ActiveSupport::Concern
Included in:
Account::UsersController
Defined in:
app/controllers/concerns/account/users/controller_base.rb

Instance Method Summary collapse

Instance Method Details

#editObject

GET /account/users/1/edit



20
21
# File 'app/controllers/concerns/account/users/controller_base.rb', line 20

def edit
end

#showObject

GET /account/users/1



24
25
# File 'app/controllers/concerns/account/users/controller_base.rb', line 24

def show
end

#updateObject

PATCH/PUT /account/users/1 PATCH/PUT /account/users/1.json



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/concerns/account/users/controller_base.rb', line 43

def update
  respond_to do |format|
    if updating_password_or_email? ? @user.update_with_password(user_params) : @user.update_without_password(user_params)
      # if you update your own user account, devise will normally kick you out, so we do this instead.
       current_user.reload
      format.html { redirect_to [:edit, :account, @user], notice: t("users.notifications.updated") }
      format.json { render :show, status: :ok, location: [:account, @user] }
    else
      format.html { render :edit, status: :unprocessable_entity }
      format.json { render json: @user.errors, status: :unprocessable_entity }
    end
  end
end

#updating_password?Boolean

TODO: We’re keeping this method for backward compatibility in case someone in a downstream app might be using it. At some point in the future (unclear exactly when) we should remove it.

Returns:

  • (Boolean)


33
34
35
36
37
38
39
# File 'app/controllers/concerns/account/users/controller_base.rb', line 33

def updating_password?
  ActiveSupport::Deprecation.new.warn(
    "#updating_password? is deprecated. " \
    "Use #updating_password_or_email? instead."
  )
  params[:user].key?(:password)
end

#updating_password_or_email?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/controllers/concerns/account/users/controller_base.rb', line 27

def updating_password_or_email?
  params[:user].key?(:password) || params[:user].key?(:email)
end