How to handle requests for non-existing dynamic segments in Ember?

If a user changes the dynamic segment (object identifier) ​​in the URL of an Ember application with Ember Data, what is the best practice for handling these URLs because they can refer to non-existing Model entries?

In the minimal example, you will notice that for each call with a non-existent identifier (for example, http://emberjs.jsbin.com/hurozaju/9#/color/30 ) an empty object is added to the local ember data store. This is easy to observe due to the increase in the number of "points" at the output.

App.ColorRoute application error redirects (as intended) to "colors" in the event 404 occurs when the model is retrieved by identifier.

Why is there a “new” item in the store?

Should you leave the data unchanged?

Is there a chance to prevent the creation of new objects in this case?

+3
source share
3 answers

I spend some time with this problem and I think this is a beta 7 ember-data bug. Report it on github.

+1
source

Here is sample code on how to get around this jsbin problem . This has been tested with the beta version of .7 data and works, but with the beta version of data4 it does not work.

+1
source

, , ...

ember-data github.

0

All Articles