Ember Data 1.0 Save problem


I’m migrating my app from ED 0.13 to 1.0 and found one strange place, I’ve pasted code example here.

The main problem is when backend declined the model save and return 422 with validation errors then I’ve got these in the console:

POST localhost:3000/requests 422 (Unprocessable Entity)
XHR finished loading: “http://localhost:3000/requests”.
Uncaught Object

and no console.log with ‘reject’ or error.

I’ve found that there is ‘throw reason;’ inside _commit function in ED and if I commented it out then I’ll get my ‘rejected’ in the console, but undefined for the ‘error’ object.

It looks very strange too me, because of this topic, where there is no problem with the code like this.

So, the main questions: what’s wrong with my setup and why there is ‘throw reason;’ inside ED code?

After some digging, I’ve found that this is not an ED problem, but caused by ember-auth package.

So hope this post will save anyone some time if he tries to use ED + ember-auth.

How did you go about fixing this? I am getting the same thing.

Yes, I’ve posted my investigations here

BTW, the latest version of ember-auth works okay without any fix (except for auto-finding the user)

Yeah I found that reply. Did the latest version fix this problem? I forked Ember-Auth about 2 weeks ago. It looks like it was last updated like 11 days ago. Did somebody commit a fix for this problem? Is this the fix? https://github.com/heartsentwined/ember-auth/commit/c1a93f2fece79116338129e201ac05af4ee3f73e

Does auto finding the user mean not having to constantly look up the user? Ex. When the page refreshes it has to look up the user from the server every time. If it is I thought this was strange too.

Also when I go to an AuthRedirectable route it should redirect to the login route right? Whenever I am not signed in and on one of these routes, it does not redirect to the login route likes you think it would. It doesn’t even check the finding of the user from the server this way. Is this a bug, not a feature, or I’m doing it wrong?

Yep, this is the fix for my problem, so I’ve removed overloading for the store. I don’t use auto-loading for the user and/or redirectable plugin, so I can’t confirm or deny your ideas, sorry

ember-auth dev here.

  1. That weird ED bug has been verified, and fixed, by this commit.

  2. The latest 9.x version has proper ember-data integration support, including auto-load current user.

  3. @Preston_Tighe has that issue been reported on the github repo? Otherwise I would like to know more about it.

Yes I got everything working by using this commit and my other problem was fixed by your response where I wasn’t calling super(my stupid mistake).

What were some of the things you fixed that weren’t working with Ember data as I came in after it wasn’t working? Is there a place where I can find everything about auto loading the user and everything you have changed since September I guess?

There isn’t one single place that lists the changes because there had been two major architectural changes in 9.x:

The first fix was pre- 9.x, and should future-proof changes in ember-data by using its own API - as long as ember-data doesn’t change the signature of the ajax method.

Another fix is to hard-code a store.find() call in the integration module, this being ember-data’s official api. The call is here.

Yet another layer would be general “internal” APIs in ember-auth, e.g. the switch from events to promise-backed handlers. The changelog would have a list of what has changed, and at which version.