我在我的 Notifier 模型(20 多封电子邮件)中为我的所有电子邮件使用一种布局......但有时我只想发送一封没有布局或 html 的纯文本电子邮件。我似乎无法弄清楚如何?如果我尝试发送纯文本电子邮件,我仍然会得到布局以及电子邮件中的所有 HTML。
我正在使用 Rails 2.3.8。
我在这里读到了这个猴子补丁......但这似乎表明新版本的rails已经结束了?如果我能避免的话,我真的不想要猴子补丁。
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”