Dockerized Rails 5 RC1 application not picking up updates to controllers and models in development

[亡魂溺海] 提交于 2019-12-04 18:42:11

问题


I have quite a bit of experience developing Rails 4 apps on Mac OS X + Docker Machine + Docker Compose, but something has changed with how Rails 5 is caching files in the development environment (currently testing with RC1).

After starting the application with docker-compose up, the application runs normally in development mode.

But if I make a change to a controller or model, the only way I can get that reflected in the application is to stop the server and start it back up.

So now my workflow looks something like this when I need to make a change to a controller or model:

  1. Make change to controller/model class.
  2. Stop server with Ctrl + C.
  3. Start server back up with docker-compose up.
  4. Wait on the server to start up.
  5. Run whatever I was running in the browser.

To say the least, needing to do steps 2-4 is annoying and not what I'm accustomed to from Rails 4.

I went a step further and uninstalled Spring using the Removal instructions, but I still get the same behavior.

I also searched for any settings that I could find in config/environments/development.rb related to the Rails runtime's iron grip on the model and controller classes, and I couldn't find anything. (I assume that it really wants to rely on watching the filesystem in order to selectively load changes, and something isn't being picked up from a change on Mac to VirtualBox.)

Any other ideas on what I can try? Or are there any new settings related to how this more aggressive caching works?


回答1:


I'm Using Rails 5 rc1.

Rails 5 introduced some "improvements" to code reloading, but it doesn’t seem to work with Docker on OS X.

So in config/environments/development.rb, I replaced

config.file_watcher = ActiveSupport::EventedFileUpdateChecker

with

config.file_watcher = ActiveSupport::FileUpdateChecker

It seems that for the ActiveSupport::EventedFileUpdateChecker file watcher, the change event does not occur for docker-machine shared files



来源:https://stackoverflow.com/questions/37144122/dockerized-rails-5-rc1-application-not-picking-up-updates-to-controllers-and-mod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!