某事/新的路由错误

时间:2012-06-26 18:54:41

标签: ruby-on-rails routes

我在http://bob.dev/assessments/new的“新”路径上收到了操作控制器异常。我最近在项目中添加了Devise和Sextant,并且给我提出问题的路径以前正在运行。我显然做错了,可以帮助他做对。 Thanksyou!

例外:

uninitialized constant ErrorsController (ActionController::RoutingError)

路线:

Bob::Application.routes.draw do
  devise_for :users

  mount_sextant                                   # Sextant gem #####################
  match '*not_found' => 'errors#handle404'        # visit http://bob.dev/rails/routes
  match "*path" => 'errors#handle404'             ###################################

  # resources :users                              # Authentication from scratch #####
  # resources :sessions                           ###################################

  root :to => "assessments#index"
    resources :assessments
end

最后,来自http://bob.dev/rails/routes的输出来自Sextant:

        new_user_session GET    /users/sign_in(.:format)          devise/sessions#new
            user_session POST   /users/sign_in(.:format)          devise/sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)         devise/sessions#destroy
           user_password POST   /users/password(.:format)         devise/passwords#create
       new_user_password GET    /users/password/new(.:format)     devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format)    devise/passwords#edit
                         PUT    /users/password(.:format)         devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)           devise/registrations#cancel
       user_registration POST   /users(.:format)                  devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format)          devise/registrations#new
  edit_user_registration GET    /users/edit(.:format)             devise/registrations#edit
                         PUT    /users(.:format)                  devise/registrations#update
                         DELETE /users(.:format)                  devise/registrations#destroy
       user_confirmation POST   /users/confirmation(.:format)     devise/confirmations#create
   new_user_confirmation GET    /users/confirmation/new(.:format) devise/confirmations#new
                         GET    /users/confirmation(.:format)     devise/confirmations#show
            rails_routes GET    /rails/routes(.:format)           rails/routes#index
             rails_route GET    /rails/routes/:id(.:format)       rails/routes#show
                                /*not_found(.:format)             errors#handle404
                                /*path(.:format)                  errors#handle404
                    root        /                                 assessments#index
             assessments GET    /assessments(.:format)            assessments#index
                         POST   /assessments(.:format)            assessments#create
          new_assessment GET    /assessments/new(.:format)        assessments#new
         edit_assessment GET    /assessments/:id/edit(.:format)   assessments#edit
              assessment GET    /assessments/:id(.:format)        assessments#show
                         PUT    /assessments/:id(.:format)        assessments#update
                         DELETE /assessments/:id(.:format)        assessments#destroy
                         GET    /rails/routes(.:format)           rails/routes#index
                         GET    /rails/routes/:id(.:format)       rails/routes#show

2 个答案:

答案 0 :(得分:1)

您可以安全地删除行

  match '*not_found' => 'errors#handle404'        
  match "*path" => 'errors#handle404'             

他们不需要。这将解决您的错误。虽然如果你想为你的应用程序制作自定义错误处理程序,请查看Jose的帖子中的第3个帖子http://blog.plataformatec.com.br/2012/01/my-five-favorite-hidden-features-in-rails-3-2/

答案 1 :(得分:0)

我猜测“错误”这个词是保留的,并且在一个新的依赖项中是冲突的。你可以把这些路线/控制器称为不同的东西吗?