Skip to content

Instantly share code, notes, and snippets.

@clekstro
Last active October 1, 2018 18:40
Show Gist options
  • Save clekstro/f96bf408627a3624d1eeddb411bac8df to your computer and use it in GitHub Desktop.
Save clekstro/f96bf408627a3624d1eeddb411bac8df to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
export default function () {
this.get('/categories');
this.get('/categories/:id');
this.get('/posts');
this.get('/posts/:id');
}
import { Model, hasMany } from 'ember-cli-mirage';
export default Model.extend({
posts: hasMany('post')
});
import { Model, belongsTo } from 'ember-cli-mirage';
export default Model.extend({
category: belongsTo('category')
});
export default function (server) {
let category = server.create('category', {
title: "Mystery"
});
server.createList('post', 10, { category });
}
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import { belongsTo, hasMany } from 'ember-data/relationships';
export default Model.extend({
name: attr('string'),
});
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import { belongsTo, hasMany } from 'ember-data/relationships';
export default Model.extend({
title: attr('string'),
content: attr('string')
});
import Ember from 'ember';
import { hash } from 'rsvp';
export default Ember.Route.extend({
model() {
return hash({
categories: this.store.findAll('category'),
posts: this.store.findAll('post')
});
},
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{
"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.2.2",
"ember-template-compiler": "3.2.2",
"ember-testing": "3.2.2"
},
"addons": {
"ember-data": "3.2.0",
"ember-cli-mirage": "0.4.9"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment