I’m building an employee directory for my company. I’m pulling data from a static JSON file so I’m using a custom Model Serializer to alter the data to add an ID (see this forum post).
The data is loading in via the overridden normalizePayload
method within the PersonSerializer and the route loads without error, but no data is showing up on the page.
I’ve tried returning result
directly from the method but that throws an error. I’ve tried walking the stack trace form my PeopleController’s init
method but thats a rabbit hole. I wondered if anyone could suggest a way to debug this issue and help me identify where the data is being lost.
Here’s the relevant bits of my app:
App.Router.map(function () {
this.resource('people', { path: '/people' }, function(){
this.resource('person', { path: ':person_id'});
});
});
App.PeopleRoute = Ember.Route.extend({
name: 'people',
model: function(){
return this.store.find('person');
}
});
App.PersonSerializer = DS.RESTSerializer.extend({
normalizePayload: function(type, payload) {
var result = [],
obj;
payload.forEach(function(el, index){
el['id'] = index;
result.push(el);
});
return {'person': result };
}
});
App.Person = DS.Model.extend({
First: DS.attr('string'),
Last: DS.attr('string')
});
App.PeopleController = Ember.ArrayController.extend({
sortAscending: true,
sortProperties:['First', 'Last'],
init: function(){
debugger;
}
});