我什么时候需要在 Rails 中重启服务器? [英] When do I need to restart server in Rails?

查看:37
本文介绍了我什么时候需要在 Rails 中重启服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,当我更改诸如 html.erb.css 之类的 rails 项目文件时,我不必使用 重新启动服务器>rails -s 命令.

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 command.

但我想当我想安装一个新的 gem 时,我必须这样做.问题是我试图让 jQuery 工作,所以我厌倦了一直做 rails -s.

But I think when I want to install a new gem I have to. The thing is that I'm trying to get jQuery to work, so i'm tired of doing rails -s all the time.

谁能告诉我在修改我的应用程序时我什么时候必须再次运行 rails -s 以及我什么时候可以不这样做?不这样做,我的意思是简单地刷新网页以查看更改.

Can anyone tell me when do I have to run rails -s again when I'm modifying my app and when can I afford NOT to do it? By not doing it, I mean simply refreshing the webpage to see the changes.

推荐答案

当您需要从头开始再次加载 Rails 时,您需要重新启动服务器.

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

如果您要添加或删除 gems,那么是的,您需要重新启动服务器.

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

如果您更改了 ruby​​ 版本、更改了 Gemfile 或更改了 Rails 内部类的某些内容,则需要重新启动它,否则应该没问题.但如果出现意外问题,您应该首先尝试重新启动服务器.

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.

另外,在旁注中,如果 config.cache_classes 设置为 false(我认为这是默认设置),您只会看到刷新页面的更改用于开发,但不适用于生产).

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).

为了确保每个人都会注意到,tadman 在评论中说了一件明智的事情,这里的一般经验法则是对 app/或 config/routes.rb 或 db/之外的任何内容进行更改将需要一个重新启动.

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.

这篇关于我什么时候需要在 Rails 中重启服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆