mercredi 22 avril 2015

Ember Data: Can I add extra properties when persisting data?

There's a route on our API to create a production with a POST to /productions. We have the option of passing a project_id property with the body to attach the production to a project in one go. So the request would looks as follows:

// POST to /productions

{
  title: "Production Title",
  goal_date: "2015-04-30 01:37:03",
  project_id: "prj_hash123"
}

When I store.createRecord('production', { title: "Production Title", ... });, the project_id property is stripped off and not sent with the save(). Is there a way using Ember Data to send along this request with the extra property?

Note: I have already tried modifying the RESTSerializer.serialize method, but the project_id property doesn't even make it there. I assume because it's not defined on the model, it's stripped when createRecord is called.




Aucun commentaire:

Enregistrer un commentaire