I have a Rails 3.1 app and for some reason when I change CSS, the changes don't show up. I did bundle exec rake assets:precompile
and it helped once, but now I am stuck with the old CSS no matter what.
问题:
回答1:
As your assets are now precompiled you need to clean them with the following
bundle exec RAILS_ENV=development rake rails_group=assets assets:clean
回答2:
You might want to try rake assets:clean and then rake assets:precompile
回答3:
For my production environment I had to combine a few of the above steps to get my assets recompiled.
First I had to do:
rake assets:clean
Making sure I was in the right environment
Then I needed to delete the public/assets
directory that the precompile creates (or just the file that you need to fix, application-<hash>.css
for example)
Then finally re-run
rake assets:precompile
And restart my apache server (I use passenger with apache, not tested with nginx)
回答4:
For me is was just deleting compiled css/js files from public directory.
It turned out that other dev put it there and didn't let know anyone.
回答5:
What worked for me in rails, chrome, mac :
1 - In terminal :
rake assets:clean
2 - In Sublime text or in Finder :
Delete the "Public > Assets" folder
3 - In terminal launch localhost server :
rails s
4 - In chrome :
http://localhost:3000/
5 - Reload chrome clearing cache if relevant :
cmd + shift + R
You should now be able to update your css files and see immediate changes on your localhost just reloading the page
DO NOT RUN "rake assets:precompile" in terminal because it will recreate the folder "assets" in the "public" folder and you won't be able to see updates of your css files directly in your localhost
回答6:
In case any future Googlers find this thread: I had the same problem in the test environment of a Rails 4.2.8 application. None of the above solutions worked. Setting config.serve_static_files = false
in config/environments/test.rb
solved it.
Bear in mind that this is a temporary fix as it causes all files in the public
folder to no longer be served (including 404.html, favicon.ico, robots.txt, etc).