无法在Rails 3中使用Actionmailer添加内联附件 [英] Cannot add inline attachment with actionmailer in rails 3
问题描述
安装捆绑软件后,我不再能够向附件添加嵌入式图像.这是我得到的错误:
After a bundle install I am no longer able to add inline images to attachments. This is the error I get:
NoMethodError (undefined method `type_for' for MIME::Types:Class):
app/mailers/welcome_mailer.rb:14:in `add_inline_attachment!'
因此很明显,type_for
方法是在类而不是对象上调用的.
So clearly the type_for
method is being called on a class instead of an object.
这是我添加内嵌附件的方式,它遵循 ActionMailer的指南:
Here is how I add the inline attachment, it follows the guidelines from ActionMailer:
attachments.inline['photo.png'] = File.read('path/to/photo.png')
我已经测试过该文件确实存在并且已被读取.该问题似乎与宝石有关.
I have tested that the file indeed exists and that it gets read. The issue appears to be gem-related.
推荐答案
升级到mime-types 3.1,于2016年5月22日发布.mime-types 2.x仅计划进行六次更新,并于2017年11月寿终正寝. ,此后将不再提供任何支持.
Upgrade to mime-types 3.1, released on 22 May 2016. mime-types 2.x only has six more planned updates and reaches end of life in November 2017, after which point no more support will be provided at all.
这篇关于无法在Rails 3中使用Actionmailer添加内联附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!