Chris Parry Chris Parry - 1 year ago 71
Javascript Question

Ember not detecting all attributes from server response


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 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
post, but as you can see the other attributes such as
(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

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){
url = '/' + this.namespace + '/feedstories/'
return url

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download