ruby on rails - The Asset pipeline doesn't use the fingerprinted routes for the images after precompile -


i'm loading background image bg.jpg image in scss file, style.css.scss

background: url(/assets/bg.jpg)  no-repeat center center; 

after precompilation, sprockets places copy of image in /public/assets directory fingerprinted name bg-28779d74f8a6fc51d1b46376428bed54.jpg . , can access image browser @ /assets/bg-28779d74f8a6fc51d1b46376428bed54.jpg link.

but when reaload page in browser, background image not displayed , when check css in dev tools particular element see:

background: url(/assets/bg.jpg) no-repeat center center; 

shouldn't

background: url(/assets/bg-28779d74f8a6fc51d1b46376428bed54.jpg ) no-repeat center center; 

le: i precompile assets rake assets:precompile having rails_env set production. thought idea mention since noticed many other people had problems because of this. sass-rails helpers "image-url", "asset-url" not working in rails 3.2.1

the correct answer in comments, here is:

image urls in stylesheets (that point images in asset pipeline) should use sass helper image-url("bg.jpg") instead of url('/assets/bg.jpg')

this helper uses asset pipeline find correct path name each image.

source: http://guides.rubyonrails.org/asset_pipeline.html#css-and-sass


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -