lcreid / rails-5-jade

Rails 5 with Jekyll and Node on Ubuntu 18.04
MIT License
29 stars 3 forks source link

Rails doesn't detect file changes and config.reload_classes_only_on_change makes the server too slow #22

Closed Pacn91 closed 6 years ago

Pacn91 commented 6 years ago

Hi,

First of all I don't know if this is a bug or not. Until now I've been using this command in rails development.rb environment config so the box detects changes on my files:

config.reload_classes_only_on_change = false

But now, with Rails 5.2 and Active Storage that command makes the server a lot slower, and the images takes from 10 to 40sec to load.

Is it a bug? There is another way to make the vagrant/rails detect changes on my files without making me reload the server every time I change something?

Hope you can help me! Best regards

lcreid commented 6 years ago

Thanks for reporting this, and I'm sorry this is so slow. I haven't used ActiveStorage yet, so I'll have to set up a project to try this.

And my apologies if I'm stating the obvious, but have you tried this:

Find the line near the end of config/environments/development.rb that looks like this:

config.file_watcher = ActiveSupport::EventedFileUpdateChecker

and comment it out. Then add right after that line, the following line:

config.file_watcher = ActiveSupport::FileUpdateChecker

so that the lines in config/environments/development.rb look like:

# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.file_watcher = ActiveSupport::FileUpdateChecker

Then restart the server if you've already started it. (You may also have to set config.reload_classes_only_on_change = true.)

The out-of-the-box way that rails server sees file changes doesn't work on the Vagrant shared directory. This change ensures that the Rails server sees file changes in the Vagrant shared directory.

Pacn91 commented 6 years ago

Hi,

First of all, thank you for your detailed answered. That works!

I'm quite new to Rails so I didn't knew about that alternative. BTW I didn't have to use: config.reload_classes_only_on_change = true (and thankfully, because that was the source of my problems in this 5.2 version)

Thank you again :)

Best regards!

lcreid commented 6 years ago

I'm glad that helped. Never be afraid to ask questions. No one knows everything, especially about a framework as big as Rails. All the best!