Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在FreeBSD 9.1中,Rails不会根据每个请求重新加载控制器和助手_Ruby On Rails_Ruby On Rails 4_Freebsd_Ruby On Rails 4.2 - Fatal编程技术网

Ruby on rails 在FreeBSD 9.1中,Rails不会根据每个请求重新加载控制器和助手

Ruby on rails 在FreeBSD 9.1中,Rails不会根据每个请求重新加载控制器和助手,ruby-on-rails,ruby-on-rails-4,freebsd,ruby-on-rails-4.2,Ruby On Rails,Ruby On Rails 4,Freebsd,Ruby On Rails 4.2,我发现了rails的奇怪行为。请给我一些建议 例如,我有这样一个代码: def new raise end def # raise end 我在开发模式下启动rails服务器。 在浏览器中点击“刷新”,查看 AuthenticationController中的运行时错误#新建 好的。我用“raise”这样的词来注释行: def new raise end def # raise end 在浏览器中点击“刷新”,但我再次看到如上所示的错误。即使在浏览器中,我看到注释为“ra

我发现了rails的奇怪行为。请给我一些建议

例如,我有这样一个代码:

def new
  raise
end
def
  # raise
end
我在开发模式下启动rails服务器。 在浏览器中点击“刷新”,查看

AuthenticationController中的运行时错误#新建

好的。我用“raise”这样的词来注释行:

def new
  raise
end
def
  # raise
end
在浏览器中点击“刷新”,但我再次看到如上所示的错误。即使在浏览器中,我看到注释为“raise”的代码

我的猜测是,控制器和助手等正在重新加载,但rails返回缓存结果

config/environments/development.rb:

Rails.application.configure do
  # BetterErrors::Middleware.allow_ip! '192.168.78.0/16'

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # Adds additional error checking when serving assets at runtime.
  # Checks for improperly declared sprockets dependencies.
  # Raises helpful error messages.
  config.assets.raise_runtime_errors = false

  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
end
如何启动服务器:

=> Booting Puma
=> Rails 4.2.1.rc3 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Puma 2.11.1 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://0.0.0.0:3000
有什么建议吗

更新1。 这个问题在Ubuntu 14.04中不存在,但在FreeBSD 9.1中存在

我已经创建了一个简单的应用程序,并首先在FreeBSD中进行了测试(同样的问题),然后在Ubuntu中进行了测试(没有问题)


您能为我提供如何在FreeBSD 9.1上处理此问题的建议吗?

请检查您是否真的在开发模式而不是生产模式下运行应用程序

还要检查您的缓存类是否关闭:

config.cache_classes = false

这可能对你有帮助

我终于明白了

以下是关于rails tracker的答案:


如果你使用VirtualBox+NFS,你必须在主机和客户端之间同步时间,因为Rails 4中有一些变化。

Rails 5+Vagrant+Ubuntu 16也有同样的问题。其他解决方案都不起作用(我的来宾和主机时间是同步的)

对我来说唯一有效的方法就是注释掉
config/environments/development.rb
中的以下行:

config.file_watcher = ActiveSupport::EventedFileUpdateChecker
我想我会发布这篇文章,以防其他人因类似问题访问此页面,就像我一样。

Rails.application.reloader.reloader!
使用rails控制台中的
方法(:reload!)找到源代码


(rails 6)

嘿,拉斐尔!谢谢你的回复。我已经用development.rb更新了我的问题,并证明我使用了服务器的开发模式。谢谢你,伙计-这救了我,而其他几个答案都没有!!发布在rails tracker上作为一个问题:好的。我明白了。这是NFS问题。我不知道必须设置什么配置选项,但如果我使用本地应用,一切都正常。同样的问题,我还从GemFileName设置中删除了gem listen,并且我的vagrant/mac时间已经同步,因此接受的解决方案没有帮助。但这一个做到了,谢谢!Rails 5引起了流浪者的几个问题,Rails团队并不认为这是一个问题,如:如果更多的人抱怨与流浪者相关的问题,团队会理解这不是一个模糊的发展方式。这也是我的解决办法,虽然我不是流浪汉。我正在OS X上使用本机docker beta版(截至2017年6月27日),我所有的rails 4.X应用程序都可以通过这个设置工作,除了我在rails 5上启动的这个新应用程序。从我的开发配置中注释掉了
EventedFileUpdateChecker
,它现在正在工作。我认为禁用此“功能”也解决了我在Docker OS X上遇到的一个问题,我将更新控制器中的代码,但更改未注册,因此我必须完全重新启动docker容器才能运行新的控制器代码。非常令人沮丧。到目前为止,它运行良好。如果这能解决问题,那将是一个巨大的帮助