我的route.rb
文件中有:
namespace :admin do
resources :products, :brands, :categories, :effects
end
rake routes
后,生成的路由如下:
Prefix Verb URI Pattern Controller#Action
root GET / page#index
products GET /products(.:format) products#index
product GET /products/:id(.:format) products#show
brands GET /brands(.:format) brands#index
categories GET /categories(.:format) categories#index
effects GET /effects(.:format) effects#index
admin_products GET /admin/products(.:format) admin/products#index
POST /admin/products(.:format) admin/products#create
new_admin_product GET /admin/products/new(.:format) admin/products#new
edit_admin_product GET /admin/products/:id/edit(.:format) admin/products#edit
admin_product GET /admin/products/:id(.:format) admin/products#show
PATCH /admin/products/:id(.:format) admin/products#update
PUT /admin/products/:id(.:format) admin/products#update
DELETE /admin/products/:id(.:format) admin/products#destroy
admin_brands GET /admin/brands(.:format) admin/brands#index
POST /admin/brands(.:format) admin/brands#create
new_admin_brand GET /admin/brands/new(.:format) admin/brands#new
edit_admin_brand GET /admin/brands/:id/edit(.:format) admin/brands#edit
admin_brand GET /admin/brands/:id(.:format) admin/brands#show
PATCH /admin/brands/:id(.:format) admin/brands#update
PUT /admin/brands/:id(.:format) admin/brands#update
DELETE /admin/brands/:id(.:format) admin/brands#destroy
admin_categories GET /admin/categories(.:format) admin/categories#index
POST /admin/categories(.:format) admin/categories#create
new_admin_category GET /admin/categories/new(.:format) admin/categories#new
edit_admin_category GET /admin/categories/:id/edit(.:format) admin/categories#edit
admin_category GET /admin/categories/:id(.:format) admin/categories#show
PATCH /admin/categories/:id(.:format) admin/categories#update
PUT /admin/categories/:id(.:format) admin/categories#update
DELETE /admin/categories/:id(.:format) admin/categories#destroy
admin_effects GET /admin/effects(.:format) admin/effects#index
POST /admin/effects(.:format) admin/effects#create
new_admin_effect GET /admin/effects/new(.:format) admin/effects#new
edit_admin_effect GET /admin/effects/:id/edit(.:format) admin/effects#edit
admin_effect GET /admin/effects/:id(.:format) admin/effects#show
PATCH /admin/effects/:id(.:format) admin/effects#update
PUT /admin/effects/:id(.:format) admin/effects#update
DELETE /admin/effects/:id(.:format) admin/effects#destroy
admin GET /admin(.:format) admin#index
我想知道,类似admin/brands#new
这样的控制器和动作,应该怎么生成?
楼上正解,另外可以试试
参见Rails Guide