Resources should never be nested more than 1 level deep.
These multi-level nested routes is violation of above mentioned rule.
resources :hotels do resources :food_menus do resources :categories do resources :dishes end end end
My Questions about Rails Guide Recommendation:
1. Why it is recommended to use 1 Level Deep routes?
2. Why they are saying not to enjoy Rails Nested Routes?
3. Is there any problem or overhead there?
4. One Level Nesting would cause multiple generation of a resource routes
a. One as Nested
b. Other as Non Nested
5. So On… 🙂
Answer to Q# 1,2,3 is:
If you use more than 1 level deep nesting then,
1. You need to pass object of each resource in helper
2. Rails will generate very very long Routes Helper & Url.
Show Method Url & Helper of dishes:
/hotels/:hotel_id/food_menus/:food_menu_id/categories/:category_id/dishes/:id hotel_food_menu_category_dish_path(@hotel_object, @food_menu_object, @categor_object, @dish_object )
3. Yes, It…
View original post 74 more words