I’m confused as to how nested routes and dynamic segments work with Ember.
Below is how I’ve defined a series of nested routes for a House. I’ve been following the pattern for defining routes using Dynamic Models guide found here: Specifying a Route's Model - Routing - Ember Guides
I don’t understand why I have to keep specifying the entire path in order to get access to the :house_id dynamic segment. If I don’t specify the entire path with the dynamic segment :house_id, then trying to access the :house_id in the params object in the model() hook returns undefined.
Hi @johnnyicon, it seems like there are various concepts being mixed up here. According to the router you posted here, the path for house.level-1.bathroom is /houses/:house_id/level-1/houses/:house_id/level-1/bathroom.
The house.show route also jumps out. Do you really want a /show route, or would you be better served by the house.index route?
To get the the :house_id param from the parent routes, you can use paramsFor, in your case `paramsFor(‘house’). The guides mention this in a section further down on the page you linked to: Specifying a Route's Model - Routing - Ember Guides. That will fix your issue with have to duplicate the paths. As @locks mentions, when you’re duplicating them like you have, you will also end up with a path that might not be what you expect it to be.