1
votes

Edit: Ember 1.7.1, ember-data 1.0.0-beta12

The response from the server seems correct but ember doesn't seem to load the response properly into the data. Below is the response from findQuery() on feedstories:

findQuery Response

After creating the record, the server sends the following response. Which seems correct as it is an individual record creation.

create record response

Ember loads the story_type post, but as you can see the other attributes such as global_id (which has been set to primary key in the serializer) has not been loaded. The embedded story attribue has the same problem, where some of the information is correct, (body, title, etc.) but doesn't load all the other attributes. They are set as undefined.

Ember Inspector

I think there may be something wrong with how I serialize the data on the client side. But as some of the information is being loaded, I'm not too sure. Any ideas?

Here is the adapter and serializer below:

App.FeedstorySerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
    primaryKey: 'global_id',
    attrs: {
        pin: {embedded: 'always' },
        story: {embedded: 'always'},
    },
    serializeIntoHash: function(hash, type, record, options){
        // Removed the root element from the request payload.
        // If not completed, causes issue when getting data from
        // the bundle object on the server.
        Ember.merge(hash, this.serialize(record, options));
    },
});


App.FeedstoryAdapter = App.ApplicationAdapter.extend({
    buildURL: function(type, id, record){
        this._super();
        url = '/' + this.namespace + '/feedstories/'
        return url
    }
});
1
Dumb question: are all of these attributes defined in your model?Chris Peters
@ChrisPeters Yeah, the seem to be, I'm not getting any warnings and have checked that they all are. When the findQuery executes the feedstories load correctly with all the data. When I create a new one, nothing happens and I'm expecting it to show the new story on top of the others.Chris Parry
@ChrisParry would the new one be shown at the bottom?locks

1 Answers

2
votes

From the query vs single response you're missing the root feedstory key on your json.