未定义的局部变量或方法`new_admin_company'使用新的命名空间

时间:2012-07-25 00:39:51

标签: ruby-on-rails-3 ruby-on-rails-3.2 rails-routing

我已经移动到我的rails应用程序的CRUD操作的命名空间。在我的路线文件中,我已经完成了:

namespace :admin do
      root :to => 'companies#index'
      resources :events

      resources :vacancies

      resources :contacts

      resources :companies do
        get :getCompanies, :on => :collection
      end
end

我在运行rake routes

时得到此信息
admin_root        /admin(.:format)                        admin/companies#index
                admin_events GET    /admin/events(.:format)                 admin/events#index
                             POST   /admin/events(.:format)                 admin/events#create
             new_admin_event GET    /admin/events/new(.:format)             admin/events#new
            edit_admin_event GET    /admin/events/:id/edit(.:format)        admin/events#edit
                 admin_event GET    /admin/events/:id(.:format)             admin/events#show
                             PUT    /admin/events/:id(.:format)             admin/events#update
                             DELETE /admin/events/:id(.:format)             admin/events#destroy
             admin_vacancies GET    /admin/vacancies(.:format)              admin/vacancies#index
                             POST   /admin/vacancies(.:format)              admin/vacancies#create
           new_admin_vacancy GET    /admin/vacancies/new(.:format)          admin/vacancies#new
          edit_admin_vacancy GET    /admin/vacancies/:id/edit(.:format)     admin/vacancies#edit
               admin_vacancy GET    /admin/vacancies/:id(.:format)          admin/vacancies#show
                             PUT    /admin/vacancies/:id(.:format)          admin/vacancies#update
                             DELETE /admin/vacancies/:id(.:format)          admin/vacancies#destroy
              admin_contacts GET    /admin/contacts(.:format)               admin/contacts#index
                             POST   /admin/contacts(.:format)               admin/contacts#create
           new_admin_contact GET    /admin/contacts/new(.:format)           admin/contacts#new
          edit_admin_contact GET    /admin/contacts/:id/edit(.:format)      admin/contacts#edit
               admin_contact GET    /admin/contacts/:id(.:format)           admin/contacts#show
                             PUT    /admin/contacts/:id(.:format)           admin/contacts#update
                             DELETE /admin/contacts/:id(.:format)           admin/contacts#destroy
getCompanies_admin_companies GET    /admin/companies/getCompanies(.:format) admin/companies#getCompanies
             admin_companies GET    /admin/companies(.:format)              admin/companies#index
                             POST   /admin/companies(.:format)              admin/companies#create
           new_admin_company GET    /admin/companies/new(.:format)          admin/companies#new
          edit_admin_company GET    /admin/companies/:id/edit(.:format)     admin/companies#edit
               admin_company GET    /admin/companies/:id(.:format)          admin/companies#show
                             PUT    /admin/companies/:id(.:format)          admin/companies#update
                             DELETE /admin/companies/:id(.:format)          admin/companies#destroy

然而我收到了错误:

undefined local variable or method `new_admin_company'

那么在将东西移动到命名空间时我忘了做什么?

2 个答案:

答案 0 :(得分:3)

它应该是new_admin_company_path。

答案 1 :(得分:0)

检查公司控制器中是否有“new”方法。