I have two controllers - say “food” and “images” (not related to each
other at all). Each one will have different categories; I’d like to
access them via /categories/2/food, /categories/2/images, etc.
But obviously that won’t work, will it? How would I go about setting
it up? The only way I could think of would be giving a different name
for each category… i.e: /cat_food/2/food, /cat_images/2/images… but
that looks very ugly.
I have two controllers - say “food” and “images” (not related to each
other at all). Each one will have different categories; I’d like to
access them via /categories/2/food, /categories/2/images, etc.
But obviously that won’t work, will it?
Nested resources
ActionController::Routing::Routes.draw do |map|
map.resources :categories do |category|
map.resources :foods, :images
end
end