【发布时间】:2018-09-04 22:47:04
【问题描述】:
在 Rails 5 routes.rb 中,最后我有一个包罗万象的内容:
match "*path" => "static_pages#not_found", via: :all
结合操作,这可以很好地处理无用的 URL,例如“/bla”或“/bla.html”。但是对于具有不同请求格式的现有路由,这是行不通的。例如,我有工作 URL“/authors”,而无用的“/authors.jpg”正在获取:
AuthorsController#index is missing a template for this request format and variant. request.formats: ["image/jpeg"] request.variant: []
关于开发和生产的 HTTP 406。
我希望即使我的 not_found 操作也能处理未处理的请求格式。什么是 Rails 5 方法来捕获所有请求格式?
【问题讨论】:
标签: ruby-on-rails routing ruby-on-rails-5