Reputation: 15089
I'm using Ruby on Rails 5 and I'm wondering how can I force code reloading before each request. The reason I need this is that I'm using Docker on Mac and my code lives in a NFS folder, thus the Rails mechanism for detecting code changes isn't working properly and I must reboot rails after each code change.
So, my question is: How can I force Rails to reload my code before each request?
Upvotes: 3
Views: 460
Reputation: 4930
Working solution on Rails 5.
You can use rerun gem with the following setup :
Add gem rerun
in your Gemfile
Launch server with rerun rails s
The following options may be usefull :
--dir
: allow to watch a specific directory and reload on change--background
: rerun won't read the keyboard and let you use debugger like byebug
Upvotes: 0
Reputation: 1959
You can consider using the rerun gem. This will allow you to reload a rack application on code change. Since Rails is basically a complex rack application this should work.
This will reload the entire(!) rails application every time, but it will reload.
I'm currently using it in a grape API, where I'm running it like this, and you should be able to run your rails application the same way.
bundle exec rerun 'rackup'
PS: You might want additional parameters such as port, etc. there as well.
Upvotes: 2