When do I need to restart server in Rails?

前端 未结 3 1292
夕颜
夕颜 2020-11-30 22:34

I have noticed that when I change rails project files such as a html.erb or .css, I don\'t have to restart the server with the rails -s

相关标签:
3条回答
  • 2020-11-30 23:09

    You will generally need to restart your server whenever a gem is installed or updated, if you upgrade ruby, or if you change some logic that runs during boot time (like config/boot.rb or config/database.yml). Otherwise it's generally ok not to, even if you edit/add models/controllers.

    Side note: the jquery-rails gem makes adding jquery to a project easy.

    0 讨论(0)
  • 2020-11-30 23:13

    In development you need to restart when:

    • You add/remove/update gems in your Gemfile.
    • You make some other change to the ruby environment, perhaps via rvm.
    • You change any files under config/, although routes.rb is reloaded for you.
    • You change any files that you require manually, rather than autoloading.

    In production you need to restart when:

    • You change any code or gems.

    N.B. These behaviours can be changed by editing the respective environment/<env>.rb file if desired, although the defaults are sensible.

    0 讨论(0)
  • 2020-11-30 23:15

    You need to restart you server when you need Rails to be loaded again from the start.

    If you're adding or removing gems, then yes, you will need to restart the server.

    If you change your version of ruby, change your Gemfile or change something from internal classes of Rails, you will need to restart it, otherwise it should be ok. But if unexpected problems arise, restart the server is the first thing you should try.

    Also, on a side-note, you will only see the changes just refreshing the page if config.cache_classes is set to false (which I think is the default for development, but not for production).

    Edit:

    Just to make sure everyone will notice, tadman said one wise thing at the comments, The general rule of thumb here is making changes to anything outside of app/ or config/routes.rb or db/ will require a restart.

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