Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 291
dmmd Avatar asked Sep 14 '15 18:09

dmmd


2 Answers

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.

like image 131
Kh Ammad Avatar answered Oct 22 '22 22:10

Kh Ammad


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 and run pkill -9 spring if any. Restart Rails and look if reloading works as expected.

like image 5
Alexey Shein Avatar answered Oct 23 '22 00:10

Alexey Shein