使用Devise,如何在首次密码更新时(或通常注册以外的其他操作)发送确认电子邮件(与注册电子邮件相同)?
答案 0 :(得分:0)
我是通过在create
confirmations_controller.rb
方法添加条件来实现的
def create
self.resource = resource_class.send_confirmation_instructions(resource_params)
yield resource if block_given?
if successfully_sent?(resource)
respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
else
if <condition> then
User.find_by_email(resource.email).send_confirmation_instructions
respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
else
respond_with(resource)
end
end
end