首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >每次进行更改时都需要重新启动Rails Server吗?为什么?

每次进行更改时都需要重新启动Rails Server吗?为什么?
EN

Stack Overflow用户
提问于 2013-08-16 18:13:58
回答 4查看 32.8K关注 0票数 47

每次我更改控制器或模型中的任何内容时,我都必须重新启动服务器,让它获取effect.But。这并不总是这样,它以前是正常工作的,当我更改任何内容时,但我不知道现在发生了什么?

我的Rails版本是3.2.11

在我的开发环境文件中,我让设置了config.cache_classes =false。

请帮帮我..

我的development.rb文件如下

代码语言:javascript
复制
Testapp::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # 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

  # Log error messages when you accidentally call methods on nil.
  config.whiny_nils = true

  # 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

  # Only use best-standards-support built into browsers
  config.action_dispatch.best_standards_support = :builtin

  # Raise exception on mass assignment protection for Active Record models
  config.active_record.mass_assignment_sanitizer = :strict

  # Log the query plan for queries taking more than this (works
  # with SQLite, MySQL, and PostgreSQL)
  config.active_record.auto_explain_threshold_in_seconds = 0.5

  # Do not compress assets
  config.assets.compress = false

  # Expands the lines which load the assets
  config.assets.debug = true

  config.action_mailer.default_url_options = { :host => 'localhost:3000' }

end
EN

回答 4

Stack Overflow用户

发布于 2013-08-27 18:40:34

我已经得到了答案..

在我的config/environments/development.rb文件中添加以下行之后,我的问题就解决了。

代码语言:javascript
复制
config.reload_classes_only_on_change = false
票数 64
EN

Stack Overflow用户

发布于 2013-08-19 19:47:35

在控制台中使用以下命令启动您的服务器

代码语言:javascript
复制
rails server -e development

如果未启动,请提供您的rails版本以及用于运行rails应用程序的服务器。

更多配置

将您的config/environments/development.rb文件修改为:

代码语言:javascript
复制
config.serve_static_assets = false
票数 9
EN

Stack Overflow用户

发布于 2019-08-16 05:35:06

出现这种情况的另一种情况是在虚拟化环境中,文件在主机操作系统上进行编辑,而来宾操作系统的文件事件管理器不会为文件更改生成事件。

这种情况的解决方案是在config/environments/development.rb中注释掉以下行:

代码语言:javascript
复制
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

因此,提供了:

代码语言:javascript
复制
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker

这迫使rails实际检查文件修改时间,而不是期望获得文件系统事件。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18270945

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档