如何判断滑轨是否在生产中? [英] How to tell if rails is in production?

查看:79
本文介绍了如何判断滑轨是否在生产中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 script / server -e production 在生产模式下启动Rails。做到了,我没有任何错误。但是,如何知道它是否处于生产模式?我尝试了一条不存在的路由,并且在开发中遇到了类似的错误页面。

I used script/server -e production to start rails in production mode. It did and I got no errors. However how do I tell if it is in production mode? I tried a non-existent route, and I got a similar error page I did in development.

我想如果在生产模式下,我会得到/ public文件夹中的404错误页面。

I thought if under production model, I get the 404 error page that is in my /public folder.

这是否意味着它没有在生产模式下启动?

Does it mean it didn't start in production mode?

感谢您的帮助。

推荐答案

2种简单方法:

tail -f log/production.log

如果在您点击该应用后有条目填充该日志,则表明您处于生产模式。

if there are entries populating that log after you hit the app, you're in production mode.

第二种方式:

在您的一个视图中(可能是布局不错),只需添加

in one of your views (probably the layout is good), just add

<%= "Environment: #{RAILS_ENV}" %>

这将向您显示您所运行的环境。

And that will show you what the environment that you're running in.

编辑

在以下情况下,您将看到默认例外页面,而不是任何环境中的实际错误页面:请求被视为本地(来自本地主机或127.0.0.1),您可以通过将其添加到 ApplicationController

You will see the default exception page instead of the actual error pages on any environment if the request is considered "local" (that is from localhost or 127.0.0.1), you can override this by adding this to your ApplicationController

def local_request?
  false
end

您可以在< a href = http://railsapi.com/doc/rails-v2.3.5/classes/ActionController/Rescue.html#M005437 rel = noreferrer> api

这篇关于如何判断滑轨是否在生产中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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