我正在使用Rails 2.3.11。我创建了以下方法UserMailer:Rails 2.3.11当电子邮件有附件时,ActionMailer不会呈现HTML
def rsvp_created(user, rsvp, pdf_file)
setup_email(user)
content_type "multipart/mixed"
@subject << "Your RSVP for #{rsvp.ticket.holiday.title}"
@body[:rsvp] = rsvp
attachment :content_type => 'application/pdf',
:body => File.read(pdf_file),
:filename => "#{rsvp.confirmation_number}.pdf"
end
def rsvp_cancelled(user, rsvp)
setup_email(user)
content_type "text/html"
@subject << "Cancelled RSVP for #{rsvp.ticket.holiday.title}"
@body[:rsvp] = rsvp
@body[:holiday_url] = APP_CONFIG['site_url'] + holiday_path(rsvp.ticket.holiday)
end
protected
def setup_email(user)
@recipients = "#{user.email}"
@from = APP_CONFIG['admin_email']
@subject = "[#{APP_CONFIG['site_name']}] "
@sent_on = Time.now
@body[:user] = user
end
的rsvp_cancelled工作正常,正常时发送电子邮件。但是有附件的rsvp_created电子邮件无法正常工作。它发送附加文件的电子邮件,但不提供任何文本。任何人在面对这个问题之前或知道我如何解决它?
感谢
我喜欢Rails 3.但是我正在开发一个在2.3.11开发的项目。所以我不得不忘掉Rails 3的东西。谢谢回复。 – user791715 2011-06-10 00:10:02