Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destroyRecord fails for a new unsaved record if it is not valid #3688

Closed
sergetab opened this issue Aug 21, 2015 · 2 comments
Closed

destroyRecord fails for a new unsaved record if it is not valid #3688

sergetab opened this issue Aug 21, 2015 · 2 comments

Comments

@sergetab
Copy link

After creating a new record with store.createRecord I might need to destroy it if user prefers not to save. If the new record is valid then destroyRecord deletes it (but the record still remains in the store???). But if the record is NOT valid then store is trying to make a DELETE request to the server. The url in this case is wrong, e.g. for a 'user' it makes a call to api/users/ without any id (new record doesn't have an id).
After some debugging I think the problem is here. 'currentState' in case of invalid record would be "root.deleted.inFlight", not 'root.deleted.saved'

@typeoneerror
Copy link

Just saw this behavior in 2.4.3. Call save() on a record. Server responds with 422 error. Then call destroyRecord and a DELETE call is made to api/users, not like api/users/1.

@pangratz
Copy link
Member

@typeoneerror the bugfix from #4293 is available since 2.6. Can you upgrade ember-data to that version and check if the error persists? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants