javascript - Create new record and commit transaction with ember-data -


i trying trigger adequate put request when add new record 1 many field using ember-data.

var track = genre.get('tracks').createrecord({name: "hit me baby 1 more time!"}) track.get('transaction').commit() 

this send put request '/genres' , send genre attributes , other tracks well.

// put /genres {"genre":{"name":"pop","tracks": [{"name":"hit me baby 1 more time!","genre_id":null}]}} 

but prefer sth. like:

// put /tracks {"track": {"name":"hit me baby 1 more time!", "genre_id":1}}} 

if somehow possible add additional parameter automatically put requests on /tracks. these models:

app.genre = ds.model.extend({   name:         ds.attr('string'),   tracks:       ds.hasmany('app.track') })  app.track = ds.model.extend({   genre:      ds.belongsto('app.genre'),   uri:        ds.attr('string') }) 

my bad, in rest adapter had setting:

ds.restadapter.map('app.genre', {   tracks: { embedded: 'always' } }) 

setting embedded load solved problem.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -