I'm having my routes clash which I anticipated but i cant figure out how to shallow nest a resource to get my desired result. (or at least i think shallow nesting is what needs to be done)
I'm having these 2 urls clash
category_item show page
guides/:guide_id/categories/:category_id/:id
clash with category edit, new etc.. pages
/guides/:guide_id/categories/:id/edit
I'm using the friendly id gem so it thinks 'edit' is :id
I want to change the category_item url structure to
guides/:guide_id/:category_id/:id
(minus the /categories for category_item)
This means the pages that are displayed to most people and picked up by search bots have shorter prettier urls and it stops the urls from clashing.
I just cant quite get it to happen.
here is the route
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
I only want the /categories to be removed for category_items if possible.