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.
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
rake assets:clean:all RAILS_ENV=production RAILS_GROUPS=assets
worked for me though –
Swayne config.assets.digest = true
from my dev config file to get the asset cache to invalidate when assets were changed. –
Arp 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)
You might want to try rake assets:clean and then rake assets:precompile
rake assets:clean:all RAILS_ENV=production RAILS_GROUPS=assets
..once I switched it to development
it worked nicely! :) thx. –
Swayne 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.
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
rake assets:precompile
on development just to test if everything was going to work properly on production. Then I spent 3 hours looking for this solution. Thanks! –
Crystalloid 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).
© 2022 - 2024 — McMap. All rights reserved.