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

时间:2015-09-14 18:04:43

标签: ruby-on-rails ruby 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

我的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

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

结论(没有解决方案):

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

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

3 个答案:

答案 0 :(得分:6)

请在select t.Testcase_id, CAST(REPLACE(testcase_id,'TC_CTU_','') AS UNSIGNED) as num from testcase_master t order by num 文件中添加此行。它适合我。

development.rb

注意: 设置config.reload_classes_only_on_change = false 后,我们就会发现一个非常清楚的问题:rails issue track

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

答案 1 :(得分:5)

Rails 4.1附带spring,所以它可能是你的问题。运行spring stop,然后检查是否有任何弹出进程ps ax | grep spring并运行pkill -9 spring(如果有)。重新启动Rails并查看重新加载是否按预期工作。

答案 2 :(得分:0)

检查 development.rb 文件,可能有

config.cache_classes = true

在开发环境中,每次请求都会重新加载应用程序的代码。这会缩短响应时间但是非常适合开发,因为您在进行代码更改时不必重新启动Web服务器,只需将此 false

  config.cache_classes = false