【发布时间】:2015-03-16 05:43:55
【问题描述】:
当用户在 url 本身中输入搜索字符串为 '%' 时,我遇到了错误。输入我的网址后看起来像
http://localhost:3000/search/%
现在它显示“NetworkError: 400 Bad Request - http://localhost:3000/search/%”。我想重定向到其他页面并在发生错误时显示错误的请求图像。请给我一些建议。
我附上了错误图片。
更新
我已经尝试了以下。
config/application.rb:
config.exceptions_app = self.routes
config/routes.rb:
match "/400", :to => "errors#bad_request"
它没有进入 bad_request 方法。
在日志中我收到错误
Invalid request: Invalid HTTP format, parsing fails.
【问题讨论】:
标签: ruby-on-rails ruby http routes bad-request