我有以下 profile_controller 的操作:
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
如果我将以下有效负载放入 Controller :
{"first_name":"Aieie", "phone": "+393345678909", "email": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="adc8d5ccc0ddc1c8edcac0ccc4c183cec2c0" rel="noreferrer noopener nofollow">[email protected]</a>"}
系统会生成一封确认电子邮件,即使我使用 skip_confirmation!
来跳过它。
如何避免系统发送确认邮件?
最佳答案
当您在更新时和保存之前调用它时,您需要执行以下操作:
current_user.skip_reconfirmation!
记住skip_reconfirmation!
关于ruby-on-rails - Rails - 更新发送给 Devise 用户的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45942212/