1
votes

i currently have this as my model

GalacticEmber.Testdata = DS.Model.extend({ username: DS.attr('string'), phone: DS.attr(), last: DS.attr('string'), first: DS.attr('string') });

and this is my route

GalacticEmber.IndexRoute = Ember.Route.extend({
model: function(){
    return Ember.RSVP.hash({
        testdatum: this.store.find('testdata'),

    });
},
setupController: function(controller, model){
    controller.set('content', model.testdatum);
}
});

but when i navigate to my page i get this error??

"Error while loading route: undefined "

i can navigate to my site in site.com/api/testdatum (and this is the result django REST)

{
"testdata": [
    {
        "username": "bba1", 
        "phone": 55522114, 
        "last": "abbbla", 
        "first": "bob"
    }, 
    {
        "username": "ema1", 
        "phone": 9998887765, 
        "last": "hobart", 
        "first": "johnston"
    }
]
}

i know there is no "id" because it is comming from a NoSQL database. So i also have this line in my models.js file

GalacticEmber.TestdataSerializer = DS.RESTSerializer.extend({
primaryKey: 'username'
});

stack trace for the console error::

Error while loading route: undefined ember.js:3285
logToConsole ember.js:3285
defaultActionHandlers.error ember.js:33921
triggerEvent ember.js:33996
trigger ember.js:32823
Transition.trigger ember.js:32044
handleError ember.js:33157
invokeCallback ember.js:9427
publish ember.js:9097
publishRejection ember.js:9525
DeferredActionQueues.flush ember.js:5650
Backburner.end ember.js:5741
Backburner.run ember.js:5780
Ember.run ember.js:6181
hash.error ember-data.js:8671
fire jquery.min.js:3048
self.fireWith jquery.min.js:3160
done jquery.min.js:8237
callback

what am i missing?

Thanks!

1
Can you provide the stack trace for the error?GJK
could you return testdatas as the root key ?sly7_7
added in stacktrace and i did and the error was it was looking for testdatumuser3554230
Specify the pluralization of the model in your Adapter: stackoverflow.com/questions/10875285/….user3995789

1 Answers

0
votes
'GalacticEmber.IndexRoute = Ember.Route.extend({
    model: function(){
      return Ember.RSVP.hash({
    testdatum: this.store.find('testdata'),

    });
 },
 setupController: function(controller, model){
controller.set('content', model.testdatum);
 }}
 );'

just try

 `GalacticEmber.IndexRoute = Ember.Route.extend({
 model: function(){
    return this.store.findAll('testdata'),

});
 },
 setupController: function(controller, model){
controller.set('content', model.testdatum);
}
 });`

i don't know why you try to surround this in Promise, it's promise by default.