Dockerized Rails 5 RC1应用程序未获取开发中控制器和模型的更新 [英] Dockerized Rails 5 RC1 application not picking up updates to controllers and models in development

查看:94
本文介绍了Dockerized Rails 5 RC1应用程序未获取开发中控制器和模型的更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac OS X + Docker Machine + Docker Compose上开发Rails 4应用程序方面有相当丰富的经验,但是Rails 5在开发环境中缓存文件的方式已经发生了一些变化(当前正在使用RC1进行测试)。

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).

使用 docker-compose up 启动应用程序后,该应用程序将在开发模式下正常运行。

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. 更改控制器/模型类。

  2. 使用 Ctrl + C 停止服务器。

  3. 使用 docker-compose up 启动服务器备份。

  4. 在服务器上等待启动。

  5. 运行我在浏览器中运行的任何内容。

  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.

至少可以说,需要要做步骤2-4很烦人,而不是我习惯于Rails 4。

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.

我还搜索了我在 config / environments / development.rb 中可以找到的与Rails运行时对模型和控制器类的控制权有关的任何设置,而我无法什么也找不到。 (我认为它真的是要依靠观察文件系统来有选择地加载更改,并且从Mac更改为VirtualBox并没有得到什么。)

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?

推荐答案

我正在使用Rails 5 rc1。

I'm Using Rails 5 rc1.

Rails 5对代码重装进行了一些改进,但似乎不适用于OS X上的Docker。

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

因此在 config / environments / development.rb 中,我替换了

config.file_watcher = ActiveSupport::EventedFileUpdateChecker

with

config.file_watcher = ActiveSupport::FileUpdateChecker

对于ActiveSupport :: EventedFileUpdateChecker文件监视程序,似乎不会对docker计算机共享文件发生更改事件

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

这篇关于Dockerized Rails 5 RC1应用程序未获取开发中控制器和模型的更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆