如何在Rails开发环境中测试500.html? [英] How to test 500.html in rails development env?
本文介绍了如何在Rails开发环境中测试500.html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用开发环境在Rails应用程序中测试500个错误页面。
I want to test the 500 error pages in my Rails app using the development environment.
我已经在 config / environments /中尝试过此操作development.rb
:
config.action_controller.consider_all_requests_local = false
但这似乎没有任何效果。
But this does not seem to have any effect.
推荐答案
您可以:
- 使用本地主机或127.0.0.1以外的地址访问应用程序,rails默认将其视为是本地请求
- 将
application_controller.rb
中的local_request覆盖吗?
:
- access the application using address other than localhost or 127.0.0.1 which rails considers by default to be local requests
- Override
local_request?
inapplication_controller.rb
to something like:
def local_request?
false
end
第二个停止将来自本地主机和127.0.0.1的请求视为本地请求,再加上 consider_all_requests_local = false
的本地请求,应该会向您显示500.html页面。
The second will stop rails treating requests from localhost and 127.0.0.1 as local requests which combined with consider_all_requests_local = false
should show you your 500.html page.
这篇关于如何在Rails开发环境中测试500.html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文