如何使用 Devise 和 Rails 3 从邮件程序访问 @user 或 user?
class JobMailer < ActionMailer::Base
default :from => "[email protected]"
def new_job_email_for_client
#
#
@url = "http://simplesite.com/users/login"
mail(:to => @???,
:subject => "You have created a new case on simplesite.")
end
end
我希望每个用户每次创建“工作”时都会收到一封电子邮件。在应用程序的其他部分,我可以访问 @user 和 user.email 等,但在邮件程序中我收到“未定义的错误”。
我如何访问邮件程序中当前用户的电子邮件地址(考虑到 Devise 控制着用户)?
class JobMailer < ActionMailer::Base
default :from => "[email protected]"
def new_job_email_for_client
#
#
@url = "http://simplesite.com/users/login"
mail(:to => @???,
:subject => "You have created a new case on simplesite.")
end
end
I would like each user to receive an email each and every time he/she creates a "job." In other parts of the application, I can access @user and user.email and such, but in the mailer I'm getting "undefined errors."
How can I access the current users email address in the mailer (taking into consideration that Devise is in control of Users)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是否是一个很好的方法,但这就是我让它工作的方法:
I'm not sure if this is a great way of doing it, but this is how I got it working: