config/environments/development.rb中的"consider_all_requests_local"的目的是什么?

102

这个Rails配置设置的目的是什么,它会影响我应该如何使用它?

config.action_controller.consider_all_requests_local = true

config/environments/development.rb中,默认设置为true。

谢谢,

Ethan


12
顺便提一句,在Rails 3中选项是 config.consider_all_requests_local= - diedthreetimes
2个回答

131
非本地请求将导致友好的错误页面。假定来自开发人员的本地请求会看到一个更有用的错误消息,其中包括行号和回溯信息。consider_all_requests_local 允许您的应用程序在进行请求的计算机是远程的情况下显示这些面向开发人员的消息。

11
Rails 的默认错误信息只是“勉强可以接受”的友好程度。然而,它还有另一个目的,就是不向可能想利用这些信息对您进行攻击的外部人员显示过多有关内部错误的信息。 - Gordon McCreight
这会改变响应状态和标头吗?比如,如果我尝试返回 503 ,但客户端接收到的是 500 - PJSCopeland

7
在开发阶段,我们设置:

consider_all_requests_local设置为true

因为开发人员需要查看完整的错误显示布局/视图,如下图所示。

enter image description here

但在生产环境中,我们不需要展示我们的内部编码错误,因此我们将其设置为 false:

config.consider_all_requests_local = false

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接