Sat*_*har 71 ruby-on-rails http http-status-codes http-status-code-503
如何在整个应用程序中返回Rails中的503 Service Unavailable?
另外,您如何为特定控制器执行相同操作?
Ser*_*sev 95
您可以使用 head
head 503
# or
head :service_unavailable
Run Code Online (Sandbox Code Playgroud)
iwa*_*bed 74
对于整个应用程序:
# ApplicationController
before_filter :return_unavailable_status
private
def return_unavailable_status
render :nothing => true, :status => :service_unavailable
end
Run Code Online (Sandbox Code Playgroud)
如果您想要一个自定义错误页面,您可以:
render 'custom_unavailable_page', :status => :service_unavailable
Run Code Online (Sandbox Code Playgroud)
如果您不希望它用于特定控制器:
# SomeController
skip_before_filter :return_unavailable_status
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
58711 次 |
| 最近记录: |