ruby-on-railsruby-on-rails-3cachingruby-on-rails-3.2sprockets

Rails dev environment not updating html/css/assets even after restarting server


I've been developing a site in rails, everything going relatively smooth. Suddenly my changes to the views and assets no longer show up. I change a stylesheet or some html and reload my browser at http://0.0.0.0:3000 and nothing changes. So I restart WEBrick and still nothing's changed. This is even the case if I change an image entirely.

The only way to get the new changes is to precompile the assets:

C:\Users\me\website>rake assets:precompile
C:/Ruby193/bin/ruby.exe C:/Ruby193/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets

Why is it showing production as the RAILS_ENV? Maybe my development environment somehow turned into the production environment? But even then I shouldn't need to precompile assets to get changes reflected. Anyway Rails.env.development? returns true and Rails.env.production? returns false in controllers and erb files.

I've tried deleting my /tmp directory to no avail.

I had to add the following line to config/application.rb in order to get Heroku to work with compass:

config.assets.initialize_on_precompile = false

However, removing that line didn't help my issue anyway.


Solution

  • Delete the contents of your public/assets/ directory. That's where precompiled files go, and they're served if they exist, rather than the request falling through to Sprockets. You can safely just nuke the whole directory, and things should work again.