【问题标题】:ActionDispatch::ShowExceptions - rails upgrade 2.3.x to 3.2.xActionDispatch::ShowExceptions - rails 将 2.3.x 升级到 3.2.x
【发布时间】:2013-02-15 18:48:14
【问题描述】:

在我的 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)

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

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 ruby-on-rails-3.2 ruby-on-rails-2


    【解决方案1】:

    添加以下行

    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

    如果这对你有用,请告诉我

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-08
      • 2013-10-11
      相关资源
      最近更新 更多