kurko / ember-sync

MIT License
282 stars 28 forks source link

offlineStore not saving when find new records from onlineStore #40

Closed bzeng closed 9 years ago

bzeng commented 9 years ago

Not sure if you are still working on this, and perhaps it's version issues, but just in case...

ember-data: 1.0.0-beta.17 ember-sync: 0.2.3

I'm using LSAdapter for offline and ActiveModelAdapter for online. I also have a few model specific serializers, so I defined two sets of serializers inherited from both LSSerializer and ActiveModelSerializer, and have them wired up to offlineStore and onlineStore respectively.

It seems the problem is, when the app starts, it calls emberSync.find() to find some records. Since it's the first time, nothing is in localStorage. It then tries to write to offlineStore with the record found online. However, for some reason the record.get('isNew') is always false, forcing the "operation" in DS.store.flushPendingSave() to be 'updateRecord' instead of 'createRecord'. Then it tries to update but couldn't find the record and ends up throwing exception.

Any tips on how to fix this? Thank you.

bzeng commented 9 years ago

Update: solve the saving problem... I changed the offline adapters using names like "post-offline.js" instead of the default "post.js". Now it's saving. Not entirely sure why but probably since the default adapter are used somehow which messed up the "isNew" status.

kurko commented 8 years ago

Thanks, @bzeng