我在我的production.rb环境文件中添加了以下内容。
config.action_mailer.default_url_options = {host: "domain.com"}
在我看来:
<%= tag("img", src: image_url("logo.png")) %>
但是,当我查看电子邮件中的路径时,我会看到一个image_path,而不是url。
http:///assets/logo.png
我在做什么错?
这就是它在我的应用程序中的工作方式。尝试这个
<%= image_tag(attachments['logo.png'].url, style: 'margin: 5px') %>
在生产电子邮件视图中尝试asset_path
而不是image_url
。
您需要在production.rb中指定 config.action_mailer.asset_host = "domain.com"
。然后在您的邮件视图中使用image_tag
。