【发布时间】:2011-04-08 20:16:45
【问题描述】:
我在我的 Notifier 模型(20 多封电子邮件)中为我的所有电子邮件使用一种布局......但有时我只想发送一封没有布局或 html 的纯文本电子邮件。我似乎无法弄清楚如何?如果我尝试发送纯文本电子邮件,我仍然会得到布局以及电子邮件中的所有 HTML。
我使用的是 Rails 2.3.8。
我在这里读到了这个猴子补丁......但这似乎表明新版本的rails已经结束了这个?如果我能避免的话,我真的不想要猴子补丁。
Rails - setting multiple layouts for a multipart email with mailer templates
layout "email" # use email.text.(html|plain).erb as the layout
def welcome_email(property)
subject 'New Signup'
recipients property.email
from 'welcome@test.com'
body :property => property
content_type "text/html"
end
def send_inquiry(inquire)
subject "#{inquire.the_subject}"
recipients inquire.ob.email
from "Test on behalf of #{inquire.name} <#{inquire.email}>"
body :inquire => inquire
content_type "text/plain"
end
我还有 2 个文件。
email.text.html.erb
email.text.plain.erb
它总是使用 text.html.erb... 即使 content_type 是“text/plain”
【问题讨论】:
标签: ruby-on-rails layout email actionmailer multipart