0

Let's say I have a parent model which has many children. The REST route for creating one of the children would look like this:

POST /parents/123/children

However, I can't seem to figure out how to set up an ember data model to have a parent. It wants to post to /children with a parent_id param. How can I set up Ember Data so that I can use the URL to identify the parent rather than passing a param?

Kingpin2k
  • 47,277
  • 10
  • 78
  • 96
Andrew
  • 227,796
  • 193
  • 515
  • 708
  • Ember itself doesn't do any posting/getting, Are you referring to Ember Data? – Kingpin2k Jul 04 '15 at 17:49
  • Yes, I'm using ember data rest adapter. – Andrew Jul 04 '15 at 17:53
  • You need to override ember adapter to support your custom url – xoma Jul 04 '15 at 18:09
  • Okay, how do I do that? – Andrew Jul 04 '15 at 19:11
  • Honestly Ember Data is PITA for this type of scenario, unless the new JSON API specifically supports a scenario like this, it's almost easier to avoid using Ember DATA. If you want to fight with Ember Data and get this to work I'd look at this post to get your started, http://stackoverflow.com/questions/17938294/how-do-you-create-a-custom-adapter-for-ember-js/17938593#17938593. The complex portion of your question is the fact that `children` records may potentially need to post to multiple locations depending on the type of parent, and that makes for some fun code. – Kingpin2k Jul 04 '15 at 21:35

0 Answers0