简体   繁体   中英

Rails expects me to restart on every change?

My views are working as expected; every time I change something, it is immediately reflected on the page. But every time I make a change in a controller , model , or config , I have to restart the server in order for it to show.

I start my server with rails s -e development and it states this:

  => 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

My config/environments/development.rb looks like this:

  # -*- 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

Any ideas of why I still have to restart it after each change?


Conclusion (without a solution):

At the end, it seems that this is a rails and mounted partitions bug. My Vagrant VirtualBox VM mounts a shared folder and, on doing that, rails can't properly deal with time synchronization between guest and host.

While I don't have a proper confirmation of this issue, it is what could explain the initial question.

Please add this line in your development.rb file. It work for me.

config.reload_classes_only_on_change = false

NOTE: With VirtualBox setup we have a very well know problem: rails issue track

Solution : You need to synchronize time between host and client due some changes in Rails 4.

Rails 4.1 comes with spring from the box, so it maybe your issue. Run spring stop and after that check if there are any spring processes left ps ax | grep spring ps ax | grep spring and run pkill -9 spring if any. Restart Rails and look if reloading works as expected.

Check your development.rb file, there may be

config.cache_classes = true

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, just make this false

  config.cache_classes = false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM