Rails server doesn't see code changes and reload files

前端 未结 5 1298
走了就别回头了
走了就别回头了 2020-12-24 14:12

I noticed that my rails server doesn\'t reload controllers, models and probably any other files after I change them. I use Vagrant and Rails API, and I found that some peopl

相关标签:
5条回答
  • 2020-12-24 14:41

    I've solved my problem adding below line to the development.rb file.

    config.reload_classes_only_on_change = false
    
    0 讨论(0)
  • 2020-12-24 14:42

    Add the following to config/environments/development.rb

    #config.file_watcher = ActiveSupport::EventedFileUpdateChecker
    config.file_watcher = ActiveSupport::FileUpdateChecker
    

    FileUpdateChecker will detect by polling the change of the file.

    0 讨论(0)
  • 2020-12-24 14:47

    This worked for me with ruby 2.6.5 and Rails 5.2.4.1.:

    Add the following line in config/environments/development.rb:

    config.file_watcher = ActiveSupport::EventedFileUpdateChecker
    

    along with

    config.cache_classes = false
    

    in the same file, and

    gem 'listen'
    

    in the :development group in Gemfile.

    0 讨论(0)
  • 2020-12-24 14:54

    I was having the same issue so what I did was make a quick script bump like this. Make sure you are in your app folder first.

    !#/bin/bash
    
    rake db:migrate
    echo "MIGRATED"
    rake routes
    echo "routed"
    sudo service apache2 restart
    echo "web server reloaded"
    

    Now you can just type ./bump and it will run all three commands then you know everything is loaded. I also use this method to repeat this like the command line installs for gems such as devise.

    0 讨论(0)
  • 2020-12-24 14:57

    pocari's solution worked for me but I had to wait a few seconds before a page reload, otherwise the content was not always updated.

    Adding an option to the synced_folder as described in this answer worked fine:

    config.vm.synced_folder ".", "/vagrant", type: "nfs", mount_options: ['actimeo=1']
    

    (and the change in development.rb is not necessary)

    0 讨论(0)
提交回复
热议问题