davideghz
davideghz

Reputation: 3685

Rails - update email to Devise User

I have the following profile_controller's action:

def update
  updated = if _profile_params[:password].present?
    current_user.skip_confirmation!
    current_user.update_with_password(_profile_params)
  else
    current_user.skip_confirmation!
    current_user.update(_profile_params)
  end

  if updated
    render json: ProfilePresenter::Public.new(current_user)
  else
    render status: :unprocessable_entity,
         json: Oj.dump({ errors: current_user.errors.messages })
  end
end

If I PUT to the controller the following payload:

{"first_name":"Aieie", "phone": "+393345678909", "email": "[email protected]"}

The system generates a confirmation email, even though I used skip_confirmation! to skip it.

How can I avoid the system to send the confirmation email?

Upvotes: 2

Views: 2490

Answers (2)

Ashish Jambhulkar
Ashish Jambhulkar

Reputation: 1504

As you are calling it while updating and before save, you need to do:

current_user.skip_reconfirmation!

remember skip_reconfirmation!

Upvotes: 3

davideghz
davideghz

Reputation: 3685

ok, it was an easy one. Just use .skip_reconfirmation! (doc)

Upvotes: 0

Related Questions