Rails 3.1资产管道和缓存 [英] Rails 3.1 Asset Pipeline and Caching
问题描述
我正在使用Rails 3.1的资产管道,尽管在我的本地主机上的开发环境中它似乎可以正常工作,但是在引擎场上却遇到了很大的问题.
I'm working with Rails 3.1's asset pipeline and although it seems to work flawlessly in my development environment on my localhost, I'm having huge issues with it on engine yard.
这是我的基本问题.
当我在一个scss文件中包含背景图像时:
When I include images for a background in one of my scss files:
a {
color: #3c7f8b;
font-weight: bold;
padding-left: 35px;
font-size: 13px;
display: block;
background: white url(shade.png) top right;
&:hover {
color: #222222;
background: white url(shade2.png) top right; }
&.on {
color: #222222;
background: white url(shade2.png) top right; } } }
我遇到了以下问题:即使我已经预编译了资产,浏览器也会请求/assets/shade.png
而不是实际存在的文件/assets/shade-FINGERPRINT.png
.
I run into the following issues: Even though I have precompiled my assets, the browser requests /assets/shade.png
instead of /assets/shade-FINGERPRINT.png
which is the actual file that exists.
有人知道我可以通过引用.scss文件中的资产文件夹中的图像来解决此问题吗?
Does anybody know what I can fix this issues with referencing images in my assets folder inside my .scss files?
推荐答案
Check out the answer from 'tybro0103' on this post - Rails 3.1 and Image Assets
基本上将文件从scss更改为scss.erb,然后使用asset_path帮助器方法
basically change the file from scss to scss.erb and then use the asset_path helper method
在部署前进行预编译
免责声明:我自己还没有尝试过
disclaimer: i have not tried this myself
这篇关于Rails 3.1资产管道和缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!