在 Rails 3 中从 ActionMailer 模板设置主题?
如何从 Rails 3 ActionMailer 模板设置主题?
我想把主题和身体放在一起。
在 Rails 2 中,您可以执行以下操作:(
<% controller.subject = 'Change of subject' %>
来自 http://www.quirkey.com/blog/2008/08/29/actionmailer-changing-the-subject-in-the-template/)
How do I set the subject from a Rails 3 ActionMailer template?
I'd like to keep the subject and body together.
In Rails 2 you can do the following:
<% controller.subject = 'Change of subject' %>
(from http://www.quirkey.com/blog/2008/08/29/actionmailer-changing-the-subject-in-the-template/)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://edgeguides.rubyonrails.org/action_mailer_basics.html
这里说:
如果你想要从视图访问它:
http://apidock.com/rails/ActionMailer/Base
如果您需要访问视图中的主题、视图中的收件人或收件人,您可以通过消息对象来实现
:做:
http://edgeguides.rubyonrails.org/action_mailer_basics.html
it says here that:
If you want to access it from the view:
http://apidock.com/rails/ActionMailer/Base
If you need to access the subject, from or the recipients in the view, you can do that through message object:
So you can do:
要从电子邮件视图本身设置电子邮件的主题行,您只需将以下内容放在视图文件的开头:
这适用于 Rails 3 和 4。
To set the subject line of an email from the email view itself you can simply put the following at the beginning of the view file:
This works for rails 3 and 4.