我认为 Rails 3.1 正在改变引发错误的方式.任何人都可以协助或确认这一点吗?我正在尝试使用 Rails 3.1.0.rc1 创建自定义错误页面
I think Rails 3.1 is changing the way that errors are raised. Can anyone assist or confirm this? I'm attempting to create custom errors pages with Rails 3.1.0.rc1
unless config.consider_all_requests_local rescue_from Exception, :with => :render_error rescue_from ActiveRecord::RecordNotFound, :with => :render_not_found rescue_from ActionController::RoutingError, :with => :render_not_found rescue_from ActionController::UnknownController, :with => :render_not_found rescue_from ActionController::UnknownAction, :with => :render_not_found end^^ 这不起作用.
config.consider_all_requests_local = true默认情况下,这是在我的开发环境中.我假设 Rails 3.1 删除了action_controller",但我无法在任何地方确认这一点.
That is in my development environment by default. I'm assuming Rails 3.1 removes the "action_controller" but I can't confirm this anywhere.
谢谢!
推荐答案我假设以下代码出现在您的 ApplicationController 中?
I'm assuming the following code appears in your ApplicationController?
unless config.consider_all_requests_local rescue_from Exception, :with => :render_error rescue_from ActiveRecord::RecordNotFound, :with => :render_not_found rescue_from ActionController::RoutingError, :with => :render_not_found rescue_from ActionController::UnknownController, :with => :render_not_found rescue_from ActionController::UnknownAction, :with => :render_not_found end如果是这样,请尝试替换此行:
If so, try replacing this line:
unless config.consider_all_requests_local使用这一行(我认为是 Rails 3 之前的版本):
with this line (pre Rails 3 I think):
unless ActionController::Base.consider_all_requests_local或者这个(发布 Rails 3):
or this (post Rails 3):
unless Rails.application.config.consider_all_requests_local更多推荐
Rails 3.1 错误捕获
发布评论