问题
I'm running rails on a nfs shared folder in a vagrant box. While the server (thin/webrick) is running I'm editing files in my host. But I have to keep stopping and restarting the application server to see changes reflected in the webapp. Is this normal behaviour?
回答1:
I go this issue on Vagrant box synchronising my folder with NFS.
I made a change in my application development configuration file (config/environments/development.rb
), just adding this line config.reload_classes_only_on_change = false
and it works.
Ensure that you have this config.cache_classes = false
as well, I had it by default when I setup rails application (using version 4.1.5), because where I found that workaround (http://edgeguides.rubyonrails.org/configuring.html) says that config.reload_classes_only_on_chage = false
is ignored if config.cache_classes
is true
Another solution is use vagrant Rsync synchronise mechanism, which is available from version 1.5 and have some benefits, but for me it doesn't work because I run out of space if I have to make a copy of my workspace on each virtual machine that I have.
来源:https://stackoverflow.com/questions/17051076/vagrant-shared-folder-with-rails-server