Ruby on rails Custrom 404错误,路由错误停止应用程序

Ruby on rails Custrom 404错误,路由错误停止应用程序,ruby-on-rails,ruby-on-rails-3.1,Ruby On Rails,Ruby On Rails 3.1,在ApplicationController中,我添加了: class ApplicationController < ActionController::Base # This code never reached when routing error occurs unless Rails.application.config.consider_all_requests_local rescue_from ActionController::RoutingError, with:

在ApplicationController中,我添加了:

class ApplicationController < ActionController::Base

# This code never reached when routing error occurs
unless Rails.application.config.consider_all_requests_local
  rescue_from ActionController::RoutingError, with: :render_404
  rescue_from ActionController::UnknownController, with: :render_404
  rescue_from ActionController::UnknownAction, with: :render_404
  rescue_from ActiveRecord::RecordNotFound, with: :render_404
end

您应该添加全包路线,如下所示:

match "*path", :to => "application#routing_error"

这里有更详细的内容

您的
render_404
是如何实现的?您的实现是否可能再次尝试呈现原始路径?它在应用程序控制器中实现,但未调用,因为未在上面执行rescue_from尝试在暂存/生产模式下运行,我认为它不会到达开发中的异常处理程序我尝试在生产模式下测试它,部署到heroku,但是没有运气。。。
match "*path", :to => "application#routing_error"