Rails 3.1 资产管道引用了错误的图像
在我的 application.css.scss 中,我引用了这样的图像:
body {
background: #7d9ec4 url(asset-path('background.png', image)) no-repeat fixed bottom center;
}
它位于 app/assets/images/background.png 中,并且在开发中工作得很好。
我正在部署到 Heroku,所以我需要预编译资产。运行rake assets:precompile
后,编译的文件显示在public/assets/
中,我的background.png得到这个文件名:background-876262e736e0b48500313d1a48005396.png(毫不奇怪,我知道这是指纹)。
令我困惑的是,编译后的 application-7665539658a117373a79cd8568f36315.css
尝试加载 /assets/background-61d37b9fc285589fc0016694e6f8d134.png
,这显然是错误的指纹。
所以我删除了 public/assets/ 中的所有文件并再次编译,将新文件添加到 git (并删除了旧文件),提交并推送到 Heroku - 但运气不佳:CSS 仍然使用错误的background-xyz.png
。
有人知道如何解决这个问题吗?
In my application.css.scss
I reference an image like this:
body {
background: #7d9ec4 url(asset-path('background.png', image)) no-repeat fixed bottom center;
}
It is located in app/assets/images/background.png
and it works perfectly fine in dev.
I'm deploying to Heroku, so I need to precompile the assets. After I run rake assets:precompile
the comiled files show up in public/assets/
and my background.png gets this filename: background-876262e736e0b48500313d1a48005396.png
(no surprise, I know it's the fingerprint).
What baffles me is that the compiled application-7665539658a117373a79cd8568f36315.css
tries to load /assets/background-61d37b9fc285589fc0016694e6f8d134.png
, which clearly is the wrong fingerprint.
So I deleted all files from public/assets/
and compiled again, added the new files to git (and removed the old ones), committed and pushed to Heroku - but no luck: the CSS still uses the wrong background-xyz.png
.
Does anybody know how to resolve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 Rails Github 问题跟踪器中有一个关于此的问题:
https://github.com/rails/rails/issues/2569
i think there was an issue in the Rails Github issue tracker about this:
https://github.com/rails/rails/issues/2569