Ruby-on-rails config/environments/development.rb 中“think_all_requests_local”的目的是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/373089/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 20:51:08  来源:igfitidea点击:

Purpose of "consider_all_requests_local" in config/environments/development.rb?

ruby-on-railsruby

提问by Ethan

What is the purpose of this Rails config setting...

此 Rails 配置设置的目的是什么...

config.action_controller.consider_all_requests_local = true

It's set to true by default in config/environments/development.rb.

config/environments/development.rb.

Thanks,

谢谢,

Ethan

伊森

回答by Gordon Wilson

Non-local requests result in user-friendly error pages. Local requests, assumed to come from developers, see a more useful error message that includes line numbers and a backtrace. consider_all_requests_localallows your app to display these developer-friendly messages even when the machine making the request is remote.

非本地请求会导致用户友好的错误页面。假定来自开发人员的本地请求会看到更有用的错误消息,其中包括行号和回溯。 consider_all_requests_local允许您的应用程序显示这些开发人员友好的消息,即使发出请求的机器是远程的。

回答by Touseef Murtaza

At development level we set:

在开发层面,我们设定:

consider_all_requests_local set = true

think_all_requests_local set = true

because developer needs to take a look at full error showing layout/view as you can see in the image below.

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

enter image description here

enter image description here

But at production level, we don't need to show our internal coding bug so we set false:

但是在生产级别,我们不需要显示我们的内部编码错误,所以我们设置为 false:

config.consider_all_requests_local = false

config.think_all_requests_local = false

enter image description here

enter image description here