Ruby Rails - 设计 - 发送注册确认电子邮件以执行除常规注册以外的操作

Ruby on Rails - Devise - Send sign up confirmation email on action other than usual sign up

使用 Devise,我如何在第一次密码更新时(或在正常注册以外的操作时)发送确认电子邮件(与注册电子邮件相同)?

我通过在 confirmations_controller.rb

中的 create 方法中添加一个条件来做到这一点
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