Assets 在我的 WebView 中工作正常,但由于某种原因,我的邮件程序不使用 Assets 管道。我正在尝试在邮件 View 中使用 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 中没有看到 a href 作为输出):
= asset_path("logo.png")
还放入您的特定环境文件:
config.action_mailer.default :content_type => "text/html"
像这样你确定你总是使用 HTML 作为默认内容类型。如果您在邮件中使用图像,最好将其设为 html。
关于ruby-on-rails - 带有 image_tag 的 ActionMailer 中的 Rails 3.1 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7344139/