Ruby on Rails - 设计 - 发送注册确认电子邮件,而不是通常的注册

时间:2018-05-08 14:37:51

标签: ruby-on-rails devise devise-confirmable email-confirmation

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

1 个答案:

答案 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
相关问题