rescue_from :: AbstractController :: ActionNotFound无效

vla*_*iov 9 ruby-on-rails exception actioncontroller ruby-on-rails-3.2

我有以下代码:

unless Rails.application.config.consider_all_requests_local
  rescue_from Exception, with: :render_exception
  rescue_from ActiveRecord::RecordNotFound, with: :render_exception
  rescue_from ActionController::UnknownController, with: :render_exception
  rescue_from ::AbstractController::ActionNotFound, with: :render_exception
  rescue_from ActiveRecord::ActiveRecordError, with: :render_exception
  rescue_from NoMethodError, with: :render_exception
end
Run Code Online (Sandbox Code Playgroud)

它们都完美无缺,除了:: AbstractController :: ActionNotFound

我也试过了

AbstractController::ActionNotFound
ActionController::UnknownAction
Run Code Online (Sandbox Code Playgroud)

错误:

   AbstractController::ActionNotFound (The action 'show' could not be found for ProductsController):
Run Code Online (Sandbox Code Playgroud)

Buc*_*yle 7

这个类似的问题表明你不能再捕获ActionNotFound异常了.检查链接以获取解决方法.这个使用Rack中间件来捕获404的建议看起来对我来说是最干净的.