我有我的路線衝突,我預計但我無法弄清楚如何淺層嵌套資源來獲得我想要的結果。 (或至少我覺得淺嵌套需要做什麼)不能弄清楚如何使用淺嵌套設置此路由
我在這2個網址交鋒
category_item顯示頁面
guides/:guide_id/categories/:category_id/:id
迎戰類編輯,新等。
頁/guides/:guide_id/categories/:id/edit
我使用,因此認爲 '編輯' 友好的ID寶石:ID
我想將category_item URL結構改變爲
guides/:guide_id/:category_id/:id
(減去category_item的/類別)
這意味着,顯示大多數人通過搜索機器人拿起頁面具有更短的漂亮的網址和它阻止了網站的衝突。
我只是不能完全實現它。
這裏是路線
resources :guides do
resources :categories, only: [:new, :create, :edit, :update] do
resources :category_items, path: "", shallow: true, only: [:update, :new, :create, :edit, :show]
resources :category_item_keys, path: "keys", only: [:update, :new, :create] do
get :edit, on: :collection #-> url.com/guides/:guide_id/:category_id/keys/edit
end
end
end
我只希望如果可能的話要對category_items刪除/類別。