In Rails how to set two sets of routes to one resource? (Example Category for Photos and Albums) -
i have categories
model shared both albums , photos. need use photo categories under /photos/categories
, album categories under /albums/categories
. how can this?
i tried failed. first set routes :
namespace :albums resources :categories end namespace :photos resources :categories, controller: 'photos/categories' end
then in view printed category links :
link_to category.name.titleize, photos_category_path(category)
the links fine when visit them error :
uninitialized constant photos
what doing wrong here?
thanks
i think both categories
controllers need defined in own namespace:
# controllers/albums/categories_controller.rb module albums class categoriescontroller < applicationcontroller ... end end # controllers/photos/categories_controller.rb module photos class categoriescontroller < applicationcontroller ... end end
Comments
Post a Comment