Confused on how to set up multiple 'category' controllers using REST/Resources.

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.

Is there an easier solution?

Wouldn't it make sense to have:

/food/categories /images/categories

?

Nested resources

ActionController::Routing::Routes.draw do |map|   map.resources :categories do |category|     map.resources :foods, :images   end end

that should be category.resources :foods, :images

How would I use a single category model/table if I need different categories for 'images' and 'food'?

Polymorphic associations.

http://wiki.rubyonrails.org/rails/pages/UnderstandingPolymorphicAssociations