Rails 3.1 上邮件程序中的 asset_url
我的邮件程序位于 Rails 3.1 上,它有一个内联附件。
要打开该附件,我使用以下代码:
attachments["rails.png"] = File.read("#{Rails.root}/app/assets/images/Rails.png")
有没有办法用 assets_url
之类的东西来更改它?
I have my mailer on rails 3.1 which has an inline attachment.
To open that attachment i use this code:
attachments["rails.png"] = File.read("#{Rails.root}/app/assets/images/Rails.png")
is there a way to change that with something like assets_url
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确,您希望使用资产管道的搜索功能来查找给定资产的本地路径,这样您就不必对其所在的目录进行硬编码。如果是这种情况,您需要执行以下操作
:将使用标准管道/链轮搜索来定位资产,并为您提供文件的完全限定本地路径。
If I understand correctly, you want to use the asset pipeline's search functionality to locate the local path for a given asset so you don't have to hard-code which directory it's in. If that's the case, you want to do this:
This will locate the asset using standard pipeline/sprockets searching, and give you the fully qualified local path to the file.