Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails assets don't get updated

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.

like image 972
Stpn Avatar asked Mar 09 '12 21:03

Stpn


3 Answers

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).

like image 91
BrunoF Avatar answered Nov 15 '22 19:11

BrunoF


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
like image 17
James Kyburz Avatar answered Nov 19 '22 22:11

James Kyburz


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)

like image 6
OneHoopyFrood Avatar answered Nov 19 '22 21:11

OneHoopyFrood