Currently, I am in the process of building a frontend using ember.js and ember-data to interact with a REST service. The server is successfully returning the data (verified through fiddler), but I keep encountering an error message stating
Unable to set property 'store' of undefined or null reference
. This is my JavaScript code:
window.Cube = Ember.Application.create({
LOG_TRANSITIONS: true,
LOG_TRANSITIONS_INTERNAL: true
});
var attr = DS.attr;
Cube.Subject = DS.Model.extend({
name: attr(),
change_date: attr(),
create_date: attr()
});
Cube.ApplicationAdapter = DS.RESTAdapter.extend({
namespace: 'backend/v1/api',
host: 'http://localhost:58721'
});
Cube.Store = DS.Store.extend({
revision: 12,
url: "http://localhost:58721",
adapter: Cube.ApplicationAdapter
});
Cube.IndexRoute = Ember.Route.extend({
model: function (params) {
var store = this.get('store');
return store.findAll('Subject');
}
});
The error seems to be originating from ember-data.js:
modelFor: function(key) {
if (typeof key !== 'string') {
return key;
}
var factory = this.container.lookupFactory('model:'+key);
Ember.assert("No model was found for '" + key + "'", factory);
factory.store = this; // issue here
factory.typeKey = key;
return factory;
}
In my understanding of ember, the store should automatically be set, but it always appears as null.
How can I define the model so that the store is accessible? What step am I overlooking?
Update 1: I have upgraded ember and now utilizing the following versions:
DEBUG: Ember : 1.1.0
DEBUG: Ember Data : 1.0.0-beta.3
DEBUG: Handlebars : 1.0.0
DEBUG: jQuery : 1.9.1
Nevertheless, I am receiving the subsequent errors in the console:
No model was found for 'nextObject'
Error while loading route: TypeError: Unable to set property 'store' of undefined or null reference