【发布时间】:2012-06-12 18:26:35
【问题描述】:
我想为用户设置 CRUD,仅供我的 Web 应用程序的管理员使用。 所以在 routes.rb 中:
namespace :admin do
resources :user
end
这意味着:
admin_user_index GET /admin/user(.:format) admin/user#index
POST /admin/user(.:format) admin/user#create
new_admin_user GET /admin/user/new(.:format) admin/user#new
edit_admin_user GET /admin/user/:id/edit(.:format) admin/user#edit
admin_user GET /admin/user/:id(.:format) admin/user#show
PUT /admin/user/:id(.:format) admin/user#update
DELETE /admin/user/:id(.:format) admin/user#destroy
显示,索引工作正常,但编辑和新建不能。我在 _form 第一行中不断收到此错误:
undefined method `user_path' for #
这是:
如何将 form_for 与命名空间资源一起使用?
【问题讨论】:
标签: ruby-on-rails namespaces routes crud form-for