Skip to content
This repository has been archived by the owner on Sep 27, 2020. It is now read-only.

Trying to reproduce 1637 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/models/post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import DS from 'ember-data';

export default DS.Model.extend({
user: DS.belongsTo()
});
4 changes: 3 additions & 1 deletion app/models/user.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import DS from 'ember-data';

export default DS.Model.extend({
name: DS.attr()
name: DS.attr(),

posts: DS.hasMany()
});
2 changes: 1 addition & 1 deletion app/routes/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Route from '@ember/routing/route';
export default Route.extend({

model() {
return this.store.findRecord('user', 1);
return this.store.findRecord('user', 1).catch(console.error);
}

});
3 changes: 2 additions & 1 deletion mirage/scenarios/default.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default function(server) {

server.create('user', { name: 'Yehuda' });
let user = server.create('user', { name: 'Yehuda' });
server.createList('post', 3, { user });

}
13 changes: 13 additions & 0 deletions mirage/serializers/application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
import { JSONAPISerializer } from 'ember-cli-mirage';

export default JSONAPISerializer.extend({
alwaysIncludeLinkageData: true,

keyForAttribute(attr) {
return attr.underscore();
},

keyForRelationship(modelName) {
return modelName.underscore();
},

keyForModel() { return 'user'; },

typeKeyForModel(model) { return model.modelName; },
});