Created
April 9, 2014 00:16
-
-
Save AshMartian/10212171 to your computer and use it in GitHub Desktop.
Having some issues with Ember data and specific routes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/routes/sessions.js | |
export default Ember.Route.extend({ | |
model: function(){ | |
return this.store.find('formatted-sessions', {event: this.modelFor('event').get('id')}); | |
} | |
}); | |
// app/models/formatted-sessions.js | |
export default DS.Model.extend({ | |
formatDay: DS.attr(), | |
thisSessions: DS.hasMany('session') | |
}); // Does not make a difference what is inside the model, same error | |
// Makes a call to http://127.0.0.1:8000/formattedSessions?event=528d909d25afafac19000001 | |
// Response from API | |
{ | |
"formatted-sessions": [ | |
{ | |
"formatDay": "Wednesday, December 4th 2013", | |
"thisSessions": [ | |
"52c8af1ae45da0643500004c" | |
] | |
}, | |
{ | |
"formatDay": "Thursday, December 5th 2013", | |
"thisSessions": [ | |
"52c8af1ae45da0643500004b", | |
"52c8af1ae45da0643500004a", | |
"52c8af1ae45da06435000049", | |
"52c8af1ae45da06435000048", | |
"52c8af1ae45da06435000047", | |
"52c8af1ae45da06435000046", | |
"52c8af1ae45da06435000045", | |
"52c8af1ae45da06435000044", | |
"52c8af1ae45da06435000043", | |
"52c8af1ae45da06435000042", | |
"52c8af1ae45da06435000041", | |
"52c8af1ae45da06435000040", | |
"52c8af1ae45da0643500003f" | |
] | |
} | |
], | |
"sessions": [ | |
... // Session objects from mongo | |
] | |
} | |
//Does not make a difference what data is returned, same error regardless. | |
// And this is the error returned | |
Error while loading route: TypeError: Cannot read property 'map' of undefined | |
at Ember.EnumerableUtils.map (http://localhost:8002/vendor/ember/ember.js:1865:15) | |
at Ember.Object.extend.pushMany (http://localhost:8002/vendor/ember-data/ember-data.min.js:10:2763) | |
at c.extend.load (http://localhost:8002/vendor/ember-data/ember-data.min.js:9:16905) | |
at http://localhost:8002/vendor/ember-data/ember-data.min.js:9:28425 | |
at invokeCallback (http://localhost:8002/vendor/ember/ember.js:9753:19) | |
at publish (http://localhost:8002/vendor/ember/ember.js:9423:9) | |
at Promise.publishFulfillment (http://localhost:8002/vendor/ember/ember.js:9843:7) | |
at Object.DeferredActionQueues.flush (http://localhost:8002/vendor/ember/ember.js:5893:24) | |
at Object.Backburner.end (http://localhost:8002/vendor/ember/ember.js:5984:27) | |
at Object.Backburner.run (http://localhost:8002/vendor/ember/ember.js:6023:18) ember.js:3461 | |
logToConsole ember.js:3461 | |
defaultActionHandlers.error ember.js:34908 | |
triggerEvent ember.js:34983 | |
trigger ember.js:34116 | |
Transition.trigger ember.js:33952 | |
(anonymous function) ember.js:33809 | |
invokeCallback ember.js:9753 | |
publish ember.js:9423 | |
publishRejection ember.js:9851 | |
DeferredActionQueues.flush ember.js:5893 | |
Backburner.end ember.js:5984 | |
Backburner.run ember.js:6023 | |
Ember.run ember.js:6426 | |
c.success ember-data.min.js:8 | |
fire jquery.js:1037 | |
self.fireWith jquery.js:1148 | |
done jquery.js:8074 | |
callback jquery.js:8598 | |
Transition #0: sessions: transition was aborted ember.js:3461 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment