例如,在我的Rails應用程序,我有類似:Rails的圖像和資源沒有被正確加載
.wax_seal {
background: url("wax-seal-small.png");
display: block;
height: 100px;
margin: 0 auto;
width: 92px;
}
.wax_seal:active {
background: url('wax-seal-small-broken.png');
}
在我config/environments/production.rb
文件:
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = true
我手動調用資產編譯:
bundle exec rake assets:precompile
而文件是在名稱末尾用散列創建的:
wax-seal-small-Uuhqwduhqwdoi234983jewf.png
所以這不起作用:
background: url("wax-seal-small.png");
但這個工作正常(在Chrome中,當我手動類型吧):
background: url("wax-seal-small-Uuhqwduhqwdoi234983jewf.png");
我在這裏錯過了什麼步驟?我怎樣才能讓我的CSS規則添加在那個小散列?
在config/environments/production.rb
中添加config.assets.compile = true
使其工作,但是我在Rails指南中讀到,由於顯着的性能命中,這是一個糟糕的做法。
我有這個相同的問題,我已經嘗試了2個答案(迄今)沒有運氣的兩個建議。你可以分享你的整個'production.rb'文件,以便我可以與我的比較?謝謝。 –