Skip to content

Instantly share code, notes, and snippets.

@Leooo
Last active September 5, 2017 14:38
Show Gist options
  • Save Leooo/305861d9a5e157117f350afa59215cb0 to your computer and use it in GitHub Desktop.
Save Leooo/305861d9a5e157117f350afa59215cb0 to your computer and use it in GitHub Desktop.
bug-relationship-resolve-after-api-fail
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
//import Collection from 'ember-cli-mirage/orm/collection';
import Mirage from 'ember-cli-mirage';
export default function() {
window.server = this;
this.get('/child/:id', function(schema, request){
return new Mirage.Response(404, {}, {
status: 'FAIL',
data: {},
errors: [
{
code: 'child',
message: 'bla'
}
],
meta: {}
});
});
this.get('/parents', function({customers}, request){
return {
data: this.serialize(customers.all())
}
});
};
import { hasMany, belongsTo } from 'ember-cli-mirage';
import { Model } from 'ember-cli-mirage';
export default Model.extend({
parent: belongsTo()
});
import { hasMany, belongsTo } from 'ember-cli-mirage';
import { Model } from 'ember-cli-mirage';
export default Model.extend({
child: belongsTo()
});
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
export default Model.extend({
parent: belongsTo('parent')
});
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
export default Model.extend({
child: belongsTo('child')
});
import Ember from 'ember';
export default Ember.Route.extend({
//store: Ember.inject.service(),
model() {
console.log('store', this.get('store'));
//let parent = this.get('store').createRecord('parent', {});
let parents = $.get('/parents');
return parent.constructor;
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{model}}
<br>
<br>
{
"version": "0.12.1",
"ENV": {
"ember-cli-mirage": {
"enabled": true
}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.10.2",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {
"ember-data": "2.12.1",
"ember-cli-mirage": "0.2.4"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment