Ruby on rails 在Desive/Rails中使用无法发送的电子邮件注册
我在应用程序中使用Desive(3.4.1),但我在注册过程中遇到问题。 当用户尝试使用有效但无法传递的电子邮件地址注册时,ActionMailer会引发Net::SMTPFatalError异常,用户会看到“出错”消息Ruby on rails 在Desive/Rails中使用无法发送的电子邮件注册,ruby-on-rails,devise,actionmailer,Ruby On Rails,Devise,Actionmailer,我在应用程序中使用Desive(3.4.1),但我在注册过程中遇到问题。 当用户尝试使用有效但无法传递的电子邮件地址注册时,ActionMailer会引发Net::SMTPFatalError异常,用户会看到“出错”消息 有没有办法在注册表上显示flash[:error]消息来代替它?您可以做一些事情,最简单的方法是将sendmail调用放在begin/rescue块中,如下所示: begin # Try to send mail rescue Exception => e fla
有没有办法在注册表上显示flash[:error]消息来代替它?您可以做一些事情,最简单的方法是将sendmail调用放在begin/rescue块中,如下所示:
begin
# Try to send mail
rescue Exception => e
flash[:error] = e.message # OR a more readable error like "cannot deliver email"
render :new
end
谢谢你的回答。当然,我可以用这种方法解决这个问题,但要做到这一点,我必须继承designe::RegistrationController。我认为这一定是一个不涉及设计代码的变通方法。