New default behavior for model hook


Hi, I am thinking in make some PR to change the behavior of model hook, without breaks.

The idea is the following: if the parent route is a dynamic segment route, and the current route doesn’t have a model hook, so the model hook become:

model: function() { 
   return this.modelFor(<parentModelName>) 

The idea of this, arise from this question.

Is this welcome?


I think this is a point of awkwardness, but I think a solution (which might be a larger API change) is exposing the parent controller to the child route templates in some way, rather than assigning the same model to separate controllers.

Brainstorming here, but what if instead of returning the parent route’s model from model, we made the generated controller an ObjectController / ArrayController proxy of the parent controller. Maybe that’s crazy. But it’d allow template bindings to work the same way, with shared stuff on the parent controller and route specific stuff only defined on the child controllers.



Do ObjectProxies work more than one level deep? Even if they do, it sounds like it could get messy… although I’m not altogether sure it’s a bad idea, I think it does kind of make sense for this to work somehow, it’s quite a common use case I think


Pretty sure they can be nested arbitrarily deep. There are probably some perf considerations but I haven’t totally thought it out, but nothing that couldn’t be circumvented.


@machty I liked that idea. In this way, we don’t change the responsibility of who resolve the model, but instead delegate to who know.