我正在尝试使用以下代码为我的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 (required)>'
from /vagrant/config/routes.rb:9:in `block in <top (required)>'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:337:in `instance_exec'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:337:in `eval_block'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:315:in `draw'
from /vagrant/config/routes.rb:1:in `<top (required)>'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:40:in `each'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/file_update_checker.rb:75:in `call'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/file_update_checker.rb:75:in `execute'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:27:in `updater'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/application/finisher.rb:71:in `block in <module:Finisher>'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `instance_exec'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `run'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:54:in `run_initializers'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/application.rb:300:in `initialize!'
from /vagrant/config/environment.rb:5:in `<top (required)>'
from /vagrant/config.ru:3:in `require'
from /vagrant/config.ru:3:in `block in <main>'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /vagrant/config.ru:1:in `new'
from /vagrant/config.ru:1:in `<main>'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:33:in `eval'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:33:in `load'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:42:in `for'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:170:in `load_adapter'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:74:in `start'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/thin-1.6.3/lib/thin/runner.rb:200:in `run_command'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/thin-1.6.3/lib/thin/runner.rb:156:in `run!'
from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/thin-1.6.3/bin/thin:6:in `<top (required)>'
from /home/vagrant/.rbenv/versions/2.1.3/bin/thin:23:in `load'
from /home/vagrant/.rbenv/versions/2.1.3/bin/thin:23:in `<main>'
Run Code Online (Sandbox Code Playgroud)
ActionController::UnknownAction 在Rails 3.2中被弃用,赞成AbstractController::ActionNotFound.您正在使用Rails 4,其中该类不再存在.
将您的班级名称重命名为新名称AbstractController::ActionNotFound,您应该全部设置.