2 ms·
My favourite Ember (Data) quirk: this.get('store').createRecord('ModelName', { .. attrs .. }).save().then(function (model) { // Ember.isNone(model)
by pyre 12y ago
My favourite Ember (Data) quirk:
this.get('store').createRecord('ModelName', {
.. attrs ..
}).save().then(function (model) {
// Ember.isNone(model) === true
}, function(error) {
console.error(error);
});
The fix: s/ModelName/modelName/
This works sometimes, and not others. The only indication of failure is the fact that the model is not loaded from the JSON response to the POST/PUT request. It's a subtle bug. I wasted a bunch of time tracking this down through the Ember Data internals (for a co-worker, but the original bug/typo could easily have been mine).
The other quirk is converting snake case to camel case and back:
address_1 =(to camelcase)=> address1 =(to snakecase)=> address1
Oops! We only use capital letters to determine where underscores go! ;-)
- Nemcue 12y agoThis should be quite easy to fix, one would think. If the name can't resolve to a model class then it should be very vocal about it (i.e. throw error). I think you should create an issue for it on Github if there's not one already.
- pyre 12y agoThe funny thing was that the only thing preventing it from working (even though it shouldn't) was a one or two line change in the internal code that loads payloads into models. I actually thought that it was a bug until I realized what was happening (though it was still difficult because one of the methods that was being used is/was monkey-patched on at runtime, and therefore don't exist on any of the classes in the code).