[英]Rails Prawn UnknownFormat (ActionController::UnknownFormat):
[英]rails4 // ActionController::UnknownFormat
某些漫游器或其他外部請求在重定向時導致ActionController::UnknownFormat
錯誤
是否可以在application_controller的某處添加一個萬能的方法來處理這些錯誤?
在請求中添加默認方法的配置規范(如果未指定)?
下面是一個跟蹤示例:
An ActionController::UnknownFormat occurred in main#index:
ActionController::UnknownFormat
app/controllers/main_controller.rb:17:in `index'
-------------------------------
Request:
-------------------------------
* URL : http://ownedurl.com/
* HTTP Method: GET
* IP address : 82.xxx.xxx.xxx
* Parameters : {"controller"=>"main", "action"=>"index"}
* Timestamp : 2015-06-07 20:54:32 +0200
* Server : servername
* Rails root : /var/www/ownedurl.com/releases/208
* Process: 29726
獲取請求顯然可以工作; 但它使它發生了。
對此的經驗非常感謝
這將處理不帶格式的請求:
rescue_from ActionController::UnknownFormat, with: :raise_not_found
def raise_not_found
render(text: 'Not Found', status: 404)
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.