gpt4 book ai didi

ruby-on-rails - Rails 希望我在每次更改时重新启动?

转载 作者:数据小太阳 更新时间:2023-10-29 06:35:51 27 4
gpt4 key购买 nike

我的 View 按预期工作;每次我更改某些内容时,它都会立即反射(reflect)在页面上。但是每次我在controllermodelconfig 中进行更改时,我都必须重新启动服务器才能显示。

我用 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 无法正确处理 guest 和主机之间的时间同步。

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

最佳答案

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

config.reload_classes_only_on_change = false

注意:使用 VirtualBox 设置我们有一个众所周知的问题:rails issue track

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

关于ruby-on-rails - Rails 希望我在每次更改时重新启动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32571092/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com