I would assume that these were in effect the same, but the former approach doesn’t work as expected (when I switch to a new user the model doesn’t get updated)
Is the failure of the model: approach a bug, or is it expected?
The model hook is only called when coming in from a URL, not when using any of the transitionTo methods or the linkTo helper. The setupController hook, on the other hand, is always called no matter how the route was entered.
I guess I should add that the model hook is passed the URL parameters allowing you to resolve them to the actual model object.
Is this true? Isn’t that only if the route has dynamic segments? If not, and no model is passed in the linkTo helper, it seems the model hook is called.
If this isn’t how it’s supposed to work, I have some code to change.
Do the model hook. I’m almost positive if you attempt to do modelFor(‘userPosts’) deeper in the route it won’t exist if you don’t return it from the model hook. You could still grab the controller and model from the controller tho. (I gotta go test this and make sure I’m not lying)
Whoops, yeah forget that case. I always implement my model hooks from the standpoint of what do I need to do to put the application into a state to render the requested resource starting with just the requested URL. This usually starts within the application route, returning promises along the way so I’m sure everything is ready when I need it. Then all the internal transitions, modelFor’s and linkTo’s just work.