I have a CRUD to experiment and test things with my backend, and I have noticed something strange with this two nested routes:
clients/index hits the back end
clientes/show/:id do not (when following a link)
Maybe this happens because the only source of truth is the model already loaded in index. Is that true? If I reload the show page it does hit the backend.
I don’t like this behaviour too much, but now I have just discovered that in the show route… I have nothing!!
Is Ember Data magically creating the “return this.store.findRecord” action?
What I want now is to improve the call to manage errors with promises, but I don’t know where is that call to the back end.
Posting your app/router.js file would help finding out what exactly is going on, but here are a few things that are true in general:
If you don’t specify a model hook for a route, the route will inherit its model from its parent route. So if you have band.details nested under band and you don’t specify a model hook for band.details, it will be that of band.
this.store.findRecord immediately (=not blocking rendering) returns the record if it’s already in the store and it’ll then fetch that record in the background from the back-end to keep it fresh.
this.store.findAll immediately (=not blocking rendering) returns all the records of that type if there are any in the store and it’ll re-fetch them in the background from the back-end to keep it fresh.
The last two behavior can be adjusted with adapter configuration.
Great, you have found the useful “hack” of Ember developers. Not firing the model hook when the model is passed into link-to is considered more like a bug than a feature and might soon change.