Dean
Dean

Reputation: 8998

undefined local variable or method `new_admin_company' with new namespace

I have moved to a namespace for the CRUD operations of my rails application. In my routes file i've done:

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

      resources :vacancies

      resources :contacts

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

I get this when I run 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

Yet i'm getting the error:

undefined local variable or method `new_admin_company'

So what have I forgot to do when moving things to a namespace?

Upvotes: 2

Views: 810

Answers (2)

Francisco Jacob
Francisco Jacob

Reputation: 128

check if you have the method "new" in your company controller.

Upvotes: 0

Benjamin Tan Wei Hao
Benjamin Tan Wei Hao

Reputation: 9691

It should be new_admin_company_path.

Upvotes: 3

Related Questions