json - How do you get Ember Data to recognize that the server is returning IDs for hasMany relationships? -


my server returns json responses this:

{   'book': {     'id': 252,     'name': 'the hobbit',     'tag_ids': [1, 2, 3, 5, 6, 7]    } } 

i'm using ember data's ds.restserializer, i've extended include keyforrelationship function recognizes keys ending in "_ids" hasmany relationships. thus, above code should match fine model code, looks this:

app.book = ds.model.extend({     name: ds.attr('string'),     tags: ds.hasmany('tag') }); 

the problem whenever create new book , server returns json response, ember data's store gets wrong. fails convert ids actual tag instances. instead, tags property on model literally set array of ids.

any ideas?

you should consider using ds.activemodeladapter instead of ds.restadapter. see https://stackoverflow.com/a/19209194/1345947


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -