2

我已移至我的 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'

那么,在将事物移至命名空间时,我忘记了做什么?

4

2 回答 2

3

它应该是 new_admin_company_path。

于 2012-07-25T00:49:01.683 回答
0

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

于 2012-07-25T01:40:40.403 回答