I have long been stuck in this matter. I thoroughly investigated the problem in stackoverflow and could not find a solution.
I am trying to upload JSON data to my application store with ember-data and rails API. I am using ember-cli.
The error I keep getting: Assertion Failed: Error: Assertion Failed: The response from a findAll must be an Array, not undefined
The application consists of several reports, each of which has diagrams. The server launches an API request (using uuid bound to the query string) and receives the following json response:
{
reports: [
{
id: 1,
name: "Report 1",
description: "Test Report 1",
display_order: 0,
chart_ids: [
1
]
},
{
id: 2,
name: "Report 2",
description: "Test Report 2",
display_order: 1,
chart_ids: [
5,
6
]
}
]
}
This is the route for reports:
export default Ember.Route.extend({
setupController: function(controller) {
controller.set('model', this.store.find('report'));
}
});
And my models:
var Report = DS.Model.extend({
name: DS.attr('string'),
description: DS.attr('string'),
displayOrder: DS.attr('integer'),
charts: DS.hasMany('chart', { async: true })
});
var Chart = DS.Model.extend({
reports: DS.belongsTo('report'),
config: DS.attr()
});
I am using ActiveModelAdapter and ActiveModelSerializer:
ApplicationAdapter:
export default DS.ActiveModelAdapter.extend({
namespace: 'api',
ajax: function(url, type, hash) {
if (Ember.isEmpty(hash)) {
hash = {};
}
if (Ember.isEmpty(hash.data)) {
hash.data = {};
}
hash.data.uuid = $.cookie('uuid');
this._super(url, type, hash);
}
});
And serializer:
export default DS.ActiveModelSerializer.extend();
I'm so upset right now. The Ember debugger is not very useful. Any help would be greatly appreciated.
, .