gpt4 book ai didi

ruby-on-rails-3 - 带有新命名空间的未定义局部变量或方法 `new_admin_company'

转载 作者:行者123 更新时间:2023-12-04 05:38:14 24 4
gpt4 key购买 nike

我已将 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'

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

最佳答案

它应该是 new_admin_company_path。

关于ruby-on-rails-3 - 带有新命名空间的未定义局部变量或方法 `new_admin_company',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11641204/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com