DEV Community

Chris Garrett
Chris Garrett

Posted on

Rails views not updating locally? This might be why...

We recently upgraded a Rails project from Rails 5 to 6. It was pretty smooth in general, but I noticed in development (with Docker) that views weren't updating with changes - as if they were being cached.

The culprit turned out to be this segment of config/development.rb:

# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

ActiveSupport::EventedFileUpdateChecker dislikes either Docker volumes or Windows - I'm leaning towards the latter and it being a dependency issue relating to FS notifications.

If you're hitting this issue: just comment out the config.file_watcher line and you'll be back on track.

Top comments (6)

Collapse
 
beyarz profile image
Beyar

Thank you for this, but I would not suggest fully commenting it out but instead using config.file_watcher = ActiveSupport::FileUpdateChecker instead.

See the difference here:
github.com/rails/rails/blob/cd54d9...

github.com/rails/rails/blob/93b16e...

Collapse
 
samuelaierizer profile image
Samuel Aierizer

This was the case for me too. I was using Windows with WSL2 and this solved it.

Collapse
 
safventure11000 profile image
Saf11000

This solved my problem. Thank you. :)

Collapse
 
agiboire profile image
Adrien

My savior of the day! 🙏

Collapse
 
mkdika profile image
Maikel Chandika

wow...works like charm! thank you.

Collapse
 
mohamedasan profile image
Mohamed Asan N

I was using Docker on MacOS and was trying to fix it hours. I wish I had looked at this solution a lot before 🙏 Thanks a lot 💪