404、500的自定义错误页面,但是默认的500错误消息来自何处?
目前在生产中,我收到以下文字:
Currently in production I'm getting this text:
500 Internal Server Error
If you are the administrator of this website, then please read this web application's
log file and/or the web server's log file to find out what went wrong.
该页面上没有任何HTML.该代码位于哪里?我没有 public/500.html 文件.
There isn't any HTML on that page. Where is this code situated? I don't have a public/500.html file.
在我的路线上,我有:
get "/404", :to => "errors#error_404"
get "/422", :to => "errors#error_404"
get "/500", :to => "errors#error_500"
get "/505", :to => "errors#error_505"
ErrorsController:
ErrorsController:
class ErrorsController < ApplicationController
def sub_layout
"left"
end
def error_404
render :status => 404, :formats => [:html], :layout => "white", :sub_layout => "left"
end
def error_422
render :status => 422, :formats => [:html], :layout => "white", :sub_layout => "left"
end
def error_500
render :status => 500, :formats => [:html], :layout => "white", :sub_layout => "left"
end
def error_505
render :status => 505, :formats => [:html], :layout => "white", :sub_layout => "left"
end
end
如何使其始终加载我的自定义错误?在某些错误上,它只是将这两行文本从Ruby on Rails核心抛出.我希望它每次都能提取自定义样式的错误页面!
How do I make it load my custom errors always? On some errors, it just throws those two lines of text coming somewhere from the Ruby on Rails core. I want it to pickup my custom styled error pages every time!
正在从中抛出您遇到的错误
The error you are experiencing is being thrown from
这意味着您的异常所抢救的代码本身就是在引发异常.您可以检查日志中的文本:
This means the code your exceptions are getting rescued by are themselves throwing exceptions. You can check your logs for text:
故障安全响应期间出错:
识别异常的真正根源,从而解决您的问题.
to identify what the exceptions really are originating from and thus solve your problem.