Skip to content

Instantly share code, notes, and snippets.

@bmax
Created August 28, 2014 17:50
Show Gist options
  • Save bmax/0b1b008b9541ff1785a5 to your computer and use it in GitHub Desktop.
Save bmax/0b1b008b9541ff1785a5 to your computer and use it in GitHub Desktop.
Changing buildURL according to the record type.
createRecord: function(store, type, record) {
var data = {};
var serializer = store.serializerFor(type.typeKey);
serializer.serializeIntoHash(data, type, record, { includeId: true });
if (record.get('isNew') && type.typeKey == 'room' && data.room.operation_id)
{
var op_id = data.room.operation_id;
delete data.room.operation_id;
return this.ajax(this.buildURL('operations/' + op_id + '/room', null, record), "POST", { data: data });
} else {
return this.ajax(this.buildURL(type.typeKey, null, record), "POST", { data: data });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment