【发布时间】:2018-10-24 07:01:12
【问题描述】:
我有一个场景,我需要使用 SLIM 编写的模板发送电子邮件。我用我认为必要的config 修复了我的environment/development.rb(也基于我的研究)
config.assets.precompile += %w( print.css )
config.serve_static_assets = true (still using Rails 4.1.16)
config.action_mailer.default_url_options = { host: 'http://localhost:3000' }
config.action_controller.asset_host = 'http://localhost:3000'
config.action_mailer.asset_host = config.action_controller.asset_host
我知道它在此步骤中正确指向了我的根 URL。然后在我的mailer.html.slim 我有这样的东西:
div align="left" style="border-collapse: collapse; padding-left: 30px;padding-top: 30px;padding-bottom: 30px;float:left;"
a href="http://#{App.url}"
= image_tag "images/logo-old.png", style: "display:inline-block", border: "0", alt: App.name, width: 139, height: 44, title: App.name
我已经尝试了以下方法:
= image_tag "logo-old.png"
= image_tag "assets/images/logo-old.png"
= image_url "logo-old.png"
没有任何效果,但好在它现在显示 Alt 以了解它仍在按其路径工作。
当前的= image_tag 计算结果为:
src="https://ci5.googleusercontent.com/proxy/83z0D3PVOqx-FwFFMwztfYBs5CSWHiURyxSUP6cZ3dq7Zo47k9mNPgotrijVmmWGxPHqblRTGCePqN4RrfEhHh_665
MdAQ=s0-d-e1-ft#http://localhost:3000/images/images/logo-old.png"
知道为什么应用找不到正常的管道路径吗?
而不是images/images/logo-old.png 我需要assets/images/logo-old.png
编辑:
所以为了比较结果,如果我做image_url "logo-old.png" 路径结果到/assets/logo-old.png
如果我执行image_url "images/logo-old.png",则路径结果为images/images/logo-old.png
我的图片在app/assets/images/logo-old.png
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 slim-lang