I'm using Ember v1.0.0 with Ember-Data v1.0.0-beta.3 and have run into a problem with saving newly-created models. The data needs to be saved on a server whose API is not under our control, and is not RESTful, so we're using a custom adapter.
We take the user through a series of forms to gather the data needed for the model, which we keep as a vanilla JavaScript object until they press the "save" button. At this point, we use store.createRecord and pass in the data object to create the actual model, then call the model's save method.
This calls through to our adapter's createRecord method, which serializes the data and posts it to the server. At this point we have no ID for the model because that gets generated by the server, and is returned in the response to the server request. At this point, we update the model to have the newly-generated ID.
The problem we are having is that after this process, when we navigate to our list of models, there is a "ghost" model there, with no ID, as well as the one with the proper ID. This ghost model only exists only in memory, and is not returned by the server when we refresh the list.
So, my question is: are we going about this the right way, and if so, why is the ghost model appearing and how do we prevent it from happening?
EDIT: here's some additional information. I've tried using store.push instead of store.createRecord when creating the model, but save then throws an error because the record's in the "empty" state.
I've also tried removing the record after the save (when using createRecord to instantiate it) using unloadRecord but this fails because the record's state is either root.loaded.created.uncommitted or root.loaded.created.inFlight, depending on where I place the call to unloadRecord. Anyway, it seems wrong that I should have to manually unload a leftover object - it shouldn't appear at all, and I don't know why it does!