Skip to content

Instantly share code, notes, and snippets.

@mattweldon

mattweldon/post-route.js

Last active Aug 29, 2015
Embed
What would you like to do?
Ember Nested URLs Error
// ...
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"
// ...
}
// ...
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';
}
});
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')
});
{
"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