Skip to content

Instantly share code, notes, and snippets.

@seocahill
Created March 17, 2017 17:54
Show Gist options
  • Save seocahill/74555003d5fcf5a2097acf08ef8a285b to your computer and use it in GitHub Desktop.
Save seocahill/74555003d5fcf5a2097acf08ef8a285b to your computer and use it in GitHub Desktop.
Ember mirage each-in bug
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
export default function() {
// These comments are here to help you get started. Feel free to delete them.
/*
Config (with defaults).
Note: these only affect routes defined *after* them!
*/
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
// this.namespace = ''; // make this `/api`, for example, if your API is namespaced
this.timing = 400; // delay for each request, automatically set to 0 during testing
this.get('/companies');
this.post('/companies');
this.get('/companies/:id');
this.put('/companies/:id'); // or this.patch
this.del('/companies/:id');
this.passthrough('https://services.cro.ie/**');
}
import { Factory, faker } from 'ember-cli-mirage';
export default Factory.extend({
companyNumber() { return faker.random.number(); },
companyName() { return faker.company.companyName(); },
});
import { Model } from 'ember-cli-mirage';
export default Model.extend({
});
export default function(server) {
server.createList('company', 10);
}
import DS from 'ember-data';
export default DS.Model.extend({
companyNumber: DS.attr('string'),
companyName: DS.attr('string')
});
import Ember from 'ember';
export default Ember.Route.extend({
model(params) {
return this.store.findRecord('company', params.company.id);
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{#each-in model as |key value|}}
{{key}}: {{value}}
{{/each-in}}
{
"version": "0.11.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.11.0",
"ember-data": "2.11.0",
"ember-template-compiler": "2.11.0",
"ember-testing": "2.11.0"
},
"addons": {
"ember-cli-mirage": "0.2.8"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment