0

カテゴリ モデルがあり、routes.rb には

resources :categories

これにより、次の一連のルートが生成されます。

categories_path      GET     /categories(.:format)           categories#index
                     POST    /categories(.:format)           categories#create
new_category_path    GET     /categories/new(.:format)       categories#new
edit_category_path   GET     /categories/:id/edit(.:format)  categories#edit
category_path        GET     /categories/:id(.:format)       categories#show
                     PATCH   /categories/:id(.:format)       categories#update
                     PUT     /categories/:id(.:format)       categories#update
                     DELETE  /categories/:id(.:format)       categories#destroy

ここで必要なのは、すべての GET ルートを除いて、残りのルートを「/admin」スコープの下に置くことです。そのため、作成、編集、削除などの操作は、admin/categories/:id/edit などでアクセスできます。

このスコープに言及する簡単な方法はありますか?

4

2 に答える 2

0

カテゴリのルートを 2 回定義できると思います。

resources :categories, :only => :index
resources :categories, :except => :index, :path => 'admin/categories'
于 2013-08-30T10:00:53.530 に答える