I've been running a small application that I originally wrote under Rails 3.1.0.rc4. Last night I began the transition to 3.1.0 final. Well I hit a frustrating snag in the asset pipeline. My js is fine, my css is fine; however, images included on stylesheets are NOT fine. I'm using .css.scss.erb extensions开发者_StackOverflow so that I can use both SASS and the asset_path helper to provide paths to my compiled assets.
example:
background: url(<%= asset_path "background.png" %>);
results in:
background: url('background.png');
which is a problem since the compiled asset is background-a76dde63a16fbb15fe1b4ec496b50877.png
Both image_tag and asset_path work correctly in erb views in the application, but not in the scss files. Any input would be very welcome.
If you change your .css
file to .scss
you can use the _url
and _path
helpers that sass-rails provides:
background: image_url("background.png")
will get picked up and "fingerprinted" in production.
More Info
Can't say I've used that helper, but I generally just hardcode
url(/assets/image.jpg);
精彩评论