Reputation: 3685
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
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