Last active
June 30, 2018 04:11
-
-
Save sdhull/9fa7c8bc250032994b6e01c470ed30b3 to your computer and use it in GitHub Desktop.
ED 3.1.1 bug repro
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
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
import Ember from 'ember'; | |
import { inject as service } from '@ember/service'; | |
export default Ember.Controller.extend({ | |
store: service(), | |
actions: { | |
addItem(event) { | |
event.preventDefault(); | |
let item = this.store.createRecord('item', {order: this.order}); | |
item.save().then((itm) => { | |
console.log('saved the item!', itm); | |
}); | |
} | |
}, | |
}); |
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
let id = 0; | |
export default function() { | |
window.server = this; | |
this.post('/orders', function (schema, request) { | |
id = id + 1; | |
const resp = { | |
"data": { | |
"attributes": {id}, | |
"id": id.toString(), | |
"type": "order" | |
} | |
} | |
console.log('creating order id: ', id); | |
return resp; | |
}); | |
this.post('/items', function (schema, request) { | |
id = id + 1; | |
const resp = { | |
"data": { | |
"attributes": {id}, | |
"relationships":{"order":{"data":{"type":"orders","id":"1"}}}, | |
"id": id.toString(), | |
"type": "item" | |
} | |
} | |
console.log('creating item id: ', id); | |
console.log(request); | |
return resp; | |
}); | |
}; |
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
import Model from 'ember-data/model'; | |
import attr from 'ember-data/attr'; | |
import { belongsTo, hasMany } from 'ember-data/relationships'; | |
export default Model.extend({ | |
order: belongsTo('order', {inverse: 'items'}), | |
}); |
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
import Model from 'ember-data/model'; | |
import attr from 'ember-data/attr'; | |
import { belongsTo, hasMany } from 'ember-data/relationships'; | |
export default Model.extend({ | |
items: hasMany('item', {inverse: 'order'}), | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
setupController(controller, model) { | |
this._super(controller, model); | |
let order = this.store.createRecord('order'); | |
order.save(); | |
controller.set('order', order); | |
}, | |
}); |
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
{ | |
"version": "0.15.0", | |
"ENV": { | |
"ember-cli-mirage": { | |
"enabled": true | |
} | |
}, | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.1.2", | |
"ember-template-compiler": "3.1.2", | |
"ember-testing": "3.1.2" | |
}, | |
"addons": { | |
"ember-data": "3.1.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