Rails希望我在每次更改时重新启动?

dmm*_*mmd 16 ruby ruby-on-rails ruby-on-rails-4.1

我的意见按预期进行; 每当我改变某些东西时,它会立即反映在页面上.但每次我在控制器,模型配置中进行更改时,我都必须重新启动服务器才能显示它.

我启动我的服务器,rails s -e development它说明了这一点:

  => Booting Puma
  => Rails 4.1.8 application starting in development on http://0.0.0.0:3000
  => Run `rails server -h` for more startup options
  => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
  => Ctrl-C to shutdown server
Run Code Online (Sandbox Code Playgroud)

config/environments/development.rb看起来像这样:

  # -*- encoding : utf-8 -*-
  Gvm::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 = true

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

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
  :address => "smtp.gmail.com",
  :port => 587,
  :domain => 'gmail.com',
  :user_name => '...',
  :password => '...',
  :authentication => 'plain',
  :enable_starttls_auto => true
  }

  config.action_mailer.default_url_options = { :host => "localhost:3000" }
  # Para debug apenas, é melhor que a linha abaixo seja adicionado apenas no ambiente de desenvolvimento
  config.action_mailer.raise_delivery_errors = 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

  # 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

  end
Run Code Online (Sandbox Code Playgroud)

有什么想法,为什么我还要在每次更改后重新启动它?


结论(没有解决方案):

最后,似乎这是一个rails和挂载分区的bug.我的Vagrant VirtualBox VM安装了一个共享文件夹,在这样做时,rails无法正确处理来宾和主机之间的时间同步.

虽然我没有正确确认这个问题,但它可以解释最初的问题.

Kh *_*mad 7

请在您的development.rb文件中添加此行.它对我有用.

config.reload_classes_only_on_change = false
Run Code Online (Sandbox Code Playgroud)

注意: 通过VirtualBox设置,我们有一个非常清楚的问题:rails问题跟踪

解决方案:由于Rails 4中的一些更改,您需要在主机和客户端之间同步时间.


Ale*_*ein 5

Rails 4.1附带spring包装盒,所以它可能是你的问题.运行spring stop并在此之后检查是否存在任何弹簧过程ps ax | grep spring并运行(pkill -9 spring如果有).重新启动Rails并查看重新加载是否按预期工作.