控制器以root为单一操作

时间:2013-12-26 16:49:21

标签: ruby-on-rails routing

我有一个指向root控制器的问题,它只有一个叫做index的动作。我目前的routes.rb看起来像这样:

  get 'dashboard', to: 'dashboard#index'

  resources :categories
  resources :projects do
    resources :issues
    resources :attachments
  end

  devise_for :users
  devise_scope :user do
    authenticated :user do
      root :to => 'dashboard#index'
    end
    unauthenticated :user do
      root :to => 'devise/sessions#new'
    end
  end

任何我的控制者:

class DashboardController < ApplicationController
  authorize_resource

  def index
    @test = 'test'
  end
end

但每次我输入localhost:3000时,我都会收到“NameError / 未初始化的常量仪表板“。我做错了什么?

提前致谢!

编辑: rake路线显示了这个:

    dashboard GET    /dashboard(.:format)                                 dashboard#index
              categories GET    /categories(.:format)                                categories#index
                         POST   /categories(.:format)                                categories#create
            new_category GET    /categories/new(.:format)                            categories#new
           edit_category GET    /categories/:id/edit(.:format)                       categories#edit
                category GET    /categories/:id(.:format)                            categories#show
                         PUT    /categories/:id(.:format)                            categories#update
                         DELETE /categories/:id(.:format)                            categories#destroy
          project_issues GET    /projects/:project_id/issues(.:format)               issues#index
                         POST   /projects/:project_id/issues(.:format)               issues#create
       new_project_issue GET    /projects/:project_id/issues/new(.:format)           issues#new
      edit_project_issue GET    /projects/:project_id/issues/:id/edit(.:format)      issues#edit
           project_issue GET    /projects/:project_id/issues/:id(.:format)           issues#show
                         PUT    /projects/:project_id/issues/:id(.:format)           issues#update
                         DELETE /projects/:project_id/issues/:id(.:format)           issues#destroy
     project_attachments GET    /projects/:project_id/attachments(.:format)          attachments#index
                         POST   /projects/:project_id/attachments(.:format)          attachments#create
  new_project_attachment GET    /projects/:project_id/attachments/new(.:format)      attachments#new
 edit_project_attachment GET    /projects/:project_id/attachments/:id/edit(.:format) attachments#edit
      project_attachment GET    /projects/:project_id/attachments/:id(.:format)      attachments#show
                         PUT    /projects/:project_id/attachments/:id(.:format)      attachments#update
                         DELETE /projects/:project_id/attachments/:id(.:format)      attachments#destroy
                projects GET    /projects(.:format)                                  projects#index
                         POST   /projects(.:format)                                  projects#create
             new_project GET    /projects/new(.:format)                              projects#new
            edit_project GET    /projects/:id/edit(.:format)                         projects#edit
                 project GET    /projects/:id(.:format)                              projects#show
                         PUT    /projects/:id(.:format)                              projects#update
                         DELETE /projects/:id(.:format)                              projects#destroy
        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
                    root        /                                                    dashboard#index
                    root        /                                                    devise/sessions#new

0 个答案:

没有答案