我正在尝试使用以下代码为我的RoR应用程序设置自定义错误页面:
unless Rails.application.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
Run Code Online (Sandbox Code Playgroud)
我启动Web服务器后出现问题,我收到以下错误消息:
我尝试基于其他帖子使用ActionController::UnknownAction没有::但这似乎没有用.
/vagrant/app/controllers/application_controller.rb:13:in `<class:ApplicationController>': uninitialized constant ActionController::UnknownAction (NameError)
from /vagrant/app/controllers/application_controller.rb:1:in `<top (required)>'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/inflector/methods.rb:238:in `const_get'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/inflector/methods.rb:238:in `block in constantize'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/inflector/methods.rb:236:in `each'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/inflector/methods.rb:236:in `inject'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/inflector/methods.rb:236:in `constantize'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/devise-3.4.1/app/controllers/devise_controller.rb:2:in `<top (required)>'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/devise-3.4.1/app/controllers/devise/sessions_controller.rb:1:in `<top (required)>'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/bundler/gems/activeadmin-7414104d41e5/lib/active_admin/devise.rb:55:in `<module:Devise>'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/bundler/gems/activeadmin-7414104d41e5/lib/active_admin/devise.rb:6:in `<module:ActiveAdmin>'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/bundler/gems/activeadmin-7414104d41e5/lib/active_admin/devise.rb:5:in `<top …Run Code Online (Sandbox Code Playgroud)