Rails using cached application.css despite changes

后端 未结 9 603
萌比男神i
萌比男神i 2020-12-30 00:53

I have a Rails 3.1 application that uses SASS. The application.css.scss file looks like:

@import \'reset.css\';
@import \'960.css\';
@import \'p         


        
9条回答
  •  盖世英雄少女心
    2020-12-30 01:35

    First, the usual cache clearing sanity checks might help. Clear browser cache. Clear server file cache (if you're in dev/test or can afford to in production) and sass-cache :

    rake tmp:cache:clear
    rm -fr tmp/sass-cache #or 'compass clean' if using compass
    

    If that doesn't help, maybe Rails compiled ANOTHER application.css elsewhere (that didn't get removed by the cache clearing)?

    For example, I ran compass watch app/assets/stylesheets/application.css.scss for debugging purposes and it created a public/assets/application.css file which, by virtue of it's location in public/, prevented any new application.css.scss stylesheet changes from being noticed by Rails. Once I removed it, the application again pulled from the .scss stylesheets. This is just one example of accidental overriding file creation. Try running a find on the entire application directory looking for any generated application.css files, doing this after the cache clearing to avoid those showing up in your results.

    (FYI, to avoid my specific issue, I now run compass watch with --css-dir pointed at the cache to prevent my issue

    $ compass watch app/assets/stylesheets/application.css.scss  --css-dir tmp/cache/
    

    )

提交回复
热议问题