我的视图按预期工作;每次我更改内容时,页面会立即反映出来。但是,每当我在控制器、模型或配置文件中进行更改时,我必须重新启动服务器才能看到更改后的效果。
我使用 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
有什么想法,为什么我每次更改后仍然需要重新启动它?
结论(无解决方案):
最终,看起来这是一个Rails和挂载分区的bug。我的Vagrant VirtualBox VM挂载了一个共享文件夹,在这样做时,Rails无法正确处理客户机和主机之间的时间同步。
虽然我没有得到这个问题的正式确认,但这可能是解释最初问题的原因。
config.reload_classes_only_on_change = false
吗? - Kiloreuxconfig.reload_classes_only_on_change = false
吗?我又加上了,但还是不行 :( @AlexeyShein 不,我没用spring或zeus。 - dmmdconfig/development.rb
,对吗?你也有config/environments/development.rb
吗? - basiam