Rails 3:使用 Devise 发送欢迎电子邮件 [英] Rails 3: Send welcome e-mail using Devise
本文介绍了Rails 3:使用 Devise 发送欢迎电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在用户注册我的服务时发送欢迎电子邮件?
How can I send a welcome e-mail when a user registers to my service?
另外,如何更改来自 Devise 的电子邮件 :from 和 :subject 字段?
Also, how do I change the e-mails :from and :subject field from Devise?
谢谢
推荐答案
我通过覆盖设计的确认做到了!方法:https://gist.github.com/982181
I did it by overriding devise's confirm! method: https://gist.github.com/982181
class User < ActiveRecord::Base
devise :invitable, :database_authenticatable, :registerable, :recoverable,
:rememberable, :confirmable, :validatable, :encryptable
# ...
# devise confirm! method overriden
def confirm!
welcome_message
super
end
# ...
private
def welcome_message
UserMailer.welcome_message(self).deliver
end
end
这篇关于Rails 3:使用 Devise 发送欢迎电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文