Use Rails 3.1 Asset Paths in a SCSS Partial
I have the following setup:
app/assets/stylesheets/application.css.scss
/*
*= require_self
*= require fancybox
*/
/* COLORS.. */
/* MIXINS... */
/* FONT STACKS... */
/* IMPORTS */
@import "reset";
@import "supergrid";
@import "rails";
@import "app";
@import "forms";
@import "layout";
In my various partials I'm having a real problem with the asset paths. When inside application.css.scss
or anything loaded by the manifest, I can use:
.example { background-image: image-path("background.png"); }
However, when I'm using a partial, such as my _layout.css.scss
partial, when I try the same thing the background-image property is simply omitted from the compiled file. It seems the SCSS asset helpers are not available inside par开发者_如何学Pythontials?
Has anyone gotten this to work, am I missing something obvious? Or is it simply impossible to use asset helpers in partials? If so this is a major, MAJOR problem, as my entire app structure depends on SCSS variables and mixins which are shared among the partials.
I know that variables and mixins are not shared across the sprockets manifest, so if partials cannot access the asset helpers then I'm looking at having to concatenate everything into a single scss file, which pretty much defeats the purpose of both Sass and Sprockets.
Any help would be very much appreciated!
Strange, it should work.. Just few ideas:
- Are you using up-to-date gems sass-rails and sprockets?
- Try to rename .css.scss to .scss
- Try to replace
image-path('background.png')
withasset-url('background.png', image)
orimage-url('background.png')
- Try to remove
require_self
from application.css.scss - Try to remove all directives from application.css.scss and import those files with @import
精彩评论