资产对我的Web视图工作正常,但由于某种原因,我的Mailer不使用资产管道.我想在我的邮件程序视图中使用image_tag:
=link_to image_tag("logo.png")
然而,这呈现为
<img alt="logo" src="http://mydomain.com/assets/logo.png">
代替
<img alt="logo" src="http://mydomain.com/assets/logo-xxxxxxxxx...png">
我在这里错过了什么吗?
我的设置是:
config.action_mailer.default_url_options = { :host => config.domain } config.action_mailer.asset_host = "http://" + config.domain
谢谢!
解决方法
尝试将以下内容放入您的邮件模板而不是link_to(link_to没有任何意义,因为您将此图像链接到任何内容,并且我没有在html中看到href作为输出):
= asset_path("logo.png")
还放入你的特定环境文件:
config.action_mailer.default :content_type => "text/html"
像这样,您确信始终使用HTML作为默认内容类型.如果你在邮件中使用图像,最好把它作为html.