Last active
August 29, 2015 14:27
-
-
Save mattweldon/75e8690515ae026b5188 to your computer and use it in GitHub Desktop.
Ember Nested URLs Error
This file contains hidden or 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
// ... | |
model: function(params) { | |
// ... | |
var versions = _this.store.findRecord('post-version', post.get('id')); | |
// http://localhost:4101/api/v1/posts/1/versions gets called correctly... | |
// ... but then BOOM. "Cannot read property '_internalModel' of undefined" | |
// ... | |
} | |
// ... |
This file contains hidden or 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
import DS from "ember-data"; | |
export default DS.RESTAdapter.extend({ | |
host: 'http://localhost:4101/api/v1', | |
buildURL: function(root, suffix, record) { | |
var url = this._super(); | |
return url + '/posts/' + suffix + '/versions'; | |
} | |
}); |
This file contains hidden or 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
import DS from 'ember-data'; | |
export default DS.Model.extend({ | |
post_id: DS.attr('number'), | |
version: DS.attr('number'), | |
title: DS.attr('string'), | |
body: DS.attr('string') | |
}); |
This file contains hidden or 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
{ | |
"post_versions": [ | |
{"id":13,"post_id":65,"version":1,"title":"test title", "body":"test body"} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment