Ruby on rails 为什么';t rails 2.1捕获来自于的rescue_异常?

Ruby on rails 为什么';t rails 2.1捕获来自于的rescue_异常?,ruby-on-rails,custom-exceptions,Ruby On Rails,Custom Exceptions,在我的ApplicationController中,我有 rescue_from StorageExceptions::AuthorizationFailed, :with => handle_auth_error def handle_auth_error redirect_to error_path(403) end 但是代码没有捕捉到这个错误。我已经检查了捕获到的是带有消息的NameError:“未捕获的抛出`StorageExceptions::AuthorizationF

在我的ApplicationController中,我有

rescue_from StorageExceptions::AuthorizationFailed, :with => handle_auth_error

def handle_auth_error
  redirect_to error_path(403)
end
但是代码没有捕捉到这个错误。我已经检查了捕获到的是带有消息的NameError:“未捕获的抛出`StorageExceptions::AuthorizationFailed'”


这是为什么?我如何捕捉到实际的错误?

我很难从…获取
rescue\u:我的Rails(2.3.8)应用程序中也使用了=>…
语法-我使用了另一种
rescue\u from。。。做结束
表格:

rescue_from(ActionController::InvalidAuthenticityToken) do |e|
    #TODO: Flash something?
    logger.error "! Invalid authenticity token when accessing #{request.url}"
    render(:template => 'sessions/new', :layout => 'pre_login')
end
我从来没有弄明白为什么第一种形式不起作用,尽管


希望这有帮助

似乎出于某种原因,该错误被转换为堆栈中某个地方的namererror。我想不出为什么,因为我找不到它是在哪里被称为NameError的。以哈迪斯的名义,什么是“没有救援就执行行动”?我到处都找不到