简体   繁体   中英

Rails: Problems with Asset Pipelin / SASS

I have a strange problem with rails assets pipeline. In my assets/stylesheets folder there is an normal application.css as well as some gmaps4rails css files, and there is a sass subfolder with an application.sass inside. Now something must have happend, when I change for example body cursor to pointer, having the web site open locally with rails s, then in the included compiled application.css there was no change. Where can I look why this suddenly happens? How should the sass and css files be included?

Thank you!

You mean that changes you make in the css / sass files are not getting reflected when you do something like "view page source".

One thing, You should disable asset pipelining in development mode. It precompiles the assets and sometimes assets don't get loaded up correctly. I have even noticed flash not getting cleared up! However you can try this:

1) Clear your browser cache.

2) In your rails app folder, go to tmp/ and delete the cache folder.

3) Now, restart your rails server.

If application.css uses //=require_tree to load the stylesheet you should rename the sass file

sass/appplication.css.sass

Only Sass recognizes pure sass files. Sprockets relies on the last extension name and thus doesn'recognize a stylesheet.

However you can also rely on sass for including other files:

# application.sass.css
//= require_self

@import "sass/application";

and leave the sass file as is.

Depending on your environment(specific to production), config.assets.compile = true should help. Which is not advised.

Preferred, run

 rake assets:precompile

after every asset pipline change.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM