Rails routes question. Always find by name and remove /class_name/ from route
- by Hock
I have a Category model and a Product model.
Category has_many products
and
Product belongs_to Category
I want my routes to be like this:
/:category_type/:category_name/ opens Product#index
/:category_type/ opens Category#show
/ opens Category#index
Is there a way to achieve that with resources? I tried with path_prefix but I just can't get it done.
Any help?
Thanks,
Nicolás Hock Isaza