2

在我的rails2.3.11 app/controllers/application_controller.rb我有这个

ActionDispatch::ShowExceptions::rescue_responses["ActionController::RoutingError"] = :not_found

现在此功能已在rails-3.2.11中弃用,我正在获取此服务器日志

DEPRECATION WARNING: ActionDispatch::ShowExceptions.rescue_responses is deprecated. Please configure your exceptions using a railtie or in your application config instead. (called from ApplicationController at /home/mbussey/demo/app/controllers/application_controller.rb:31)

可能是我的问题是重复的,但我需要有关如何ActionDispatch::ShowExceptions::rescue_responses在 rails3.2.11 中设置的具体帮助,所以我无法收到已弃用的警告。

4

1 回答 1

3

添加以下行

config.action_dispatch.rescue_responses["ActionController::RoutingError"] = :not_found

或者你可以

config.action_dispatch.rescue_responses.merge!( 'ActionController::RoutingError' => :not_found)

config/environments/env 文件中,您应该能够添加(production.rb、development.rb 或 test.rb)或config/application.rb用于所有环境

请让我知道这是否适合您

于 2013-02-18T19:46:55.410 回答