[英]Rails doesn't detect file changes and config.reload_classes_only_on_change makes the server too slow
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:
到目前为止,我一直在 rails development.rb 环境配置中使用此命令,因此该框可以检测到我的文件的更改:
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.但是现在,使用 Rails 5.2 和 Active Storage,该命令会使服务器速度变慢,加载图像需要 10 到 40 秒。
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?
还有另一种方法可以让 vagrant/rails 检测到我的文件上的更改,而无需每次更改某些内容时都让我重新加载服务器?
Solution:解决方案:
After questioning the owner of the box I've been using, he gave me this alternative that works:在询问了我一直在使用的盒子的主人之后,他给了我这个可行的替代方案:
At the bottom of the config/environments/development.rb
I did this change:在
config/environments/development.rb
我做了这个改变的底部:
Find this line at the bottom of the file and comment out:在文件底部找到这一行并注释掉:
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
Then add this line:然后添加这一行:
config.file_watcher = ActiveSupport::FileUpdateChecker
So it looks like this:所以它看起来像这样:
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.file_watcher = ActiveSupport::FileUpdateChecker
Now it works properly and I do not have to use this command anymore:现在它可以正常工作了,我不必再使用这个命令了:
config.reload_classes_only_on_change = true
Best regards!此致!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.