Search code examples
ruby-on-railsruby-on-rails-3ruby-on-rails-3.1ruby-on-rails-3.2ruby-on-rails-2

ActionDispatch::ShowExceptions - rails upgrade 2.3.x to 3.2.x


In my rails2.3.11 app/controllers/application_controller.rb I have this

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

now this feature is deprecated in rails-3.2.11, I am getting this server log

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)

May be my question is duplicated but I need specific help on How to set ActionDispatch::ShowExceptions::rescue_responses in rails3.2.11, so I can't get deprecated warning.


Solution

  • Add following line

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

    or you can

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

    In config/environments/ env files you should be able to add (production.rb, development.rb or test.rb) or config/application.rb for all environments

    please let me know if this will work for you