So, I have (as I think) a common w / Ember-data problem. I am wondering how to properly configure the adapter to adapt to the following situation.
Pretend I have two objects: Post and Tag
Calling App.Post.find() returns all GET ing api.com/posts , App.Post.find(1) is located at api.com/posts/1 . It's good.
App.Tag.find() will return all tags available at api.com/tags . App.Tag.find(1) will return the corresponding tag at the correct URL. Also good.
If I create new messages through App.Post.createRecord({...}) , it will Post to the correct URL. The same goes for creating Tags . Bye all dandy.
Tags on a Post are embedded because they are "on" which are published.
App.Adapter.map("App.Post", { tags: {embedded: 'always'} });
At boot time, Ember-data does everything right, and I'm still very happy.
So my problem is adding Tag to Post . I would like a PUT or Post tag object api.com/posts/1/tags , where the server will perform all actions on the server side.
Currently
Ember-data with the configuration set {embedded: 'always'} will send the PUT to api.com/posts/1 with the entire Post object (with the new Tag object) as a string with a JSON string.
Without the set {embedded: 'always'} config, ember-data will try the PUT tag object api.com/tags and send the Tag object with the post_id parameter so that the server side can perform all actions on the server side.
I would rather not do 1 because my server is not configured this way. I would prefer not to do 2 because PUT/POST/GET on api.com/tags really should be for the tag management part of my application and not apply tags to messages. Another example of this behavior is the Github v3 API for shortcuts and problems .
Does anyone know how to handle this with ember data? Thanks!
Brennan mcach
source share