ember.js - Empty request payload when saving new record - Ember-data -


what i'm trying:

persist new record reason request payload empty though record has data.

here's fiddle: http://jsfiddle.net/brancusi/m8vrb/16/

(disregard firebase, it's there can inspect request payload on save.)

explanation:

you notice when save record, request payload empty.

ideally request payload this:

{     "inventory": {         "entry_time": "2014-02-05",         "client_id": 1,         "user_id": 1,         "product_stock_levels": [             {                 "product_id": 1,                 "quantity": 2             },             {                 "product_id": 2,                 "quantity": 0             },             {                 "product_id": 3,                 "quantity": 8             }         ]     } } 

notes:

this seems problem when it's new record. updating existing records send correct payload.

you expecting ember data embed relationships in model on save default. not default behavior.

you define relationships being embedded per model. there no support embedded record feature anymore stated here: https://github.com/emberjs/data/blob/master/transition.md not sure if basic embedded record features still work latest version of ember data. define record embedded this:

app.inventoryserializer = ds.activemodelserializer.extend(ds.embeddedrecordsmixin, {     attrs: {         productstocklevels: {embedded: 'always'}     } }); 

because core team stopped support embedded records feature , basic recommend use embbededadapter or embeddedmixin if need support embedded records. find them here: https://github.com/pixelhandler/ember-data-extensions

but ember data embeddedadapter not stable yet. perhaps should consider not embedded records reduce complexity if flexible in defining api.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -