var id = model.get('id');
this.store.find('listingEvent', id)
.then(function(le){
var toggle = !le.get('currentUserAttending');
le.set('currentUserAttending', toggle);
le.save();
});
No matter what toggle ends up being false is always persisted to the server. Even if I hard code it as true!
Basically based on what the docs say - this should work - so I am assuming it is a bug in ember data - a pretty fundamental one at that as this is probably one of the most basic use cases!
If I don’t call .save the record correctly reflects the changes. Calling .save sends the old state to the server which responds with the old state and thus resets the copy in ember-data store.
calling.save should send the updated record surely?
Try to reproduce it in a emberjs.jsbin.com with the same versions of the libs that you are using.
This might be an issue with how your backend returns the data upon save.
Is your server providing the correct response? If your server always return true or false for the Boolean flag, after the response came back, it will automatically overwrite the flag. I’ve gotten burned by this a few times.
The reason I thought it was sending the wrong data to the server was because in the preview pane in Chrome it shows something else - but not the data that is being sent. That completely screwed me up. Once I had figured that out I realised it was sending the correct data and because the data coming back from the server wasn’t formatted correctly it was being rejected by ember and reverted…