Skip to content

Instantly share code, notes, and snippets.

@bmac
Created February 8, 2017 20:47
Show Gist options
  • Save bmac/f9a73141522b687c99192e4f56fe9648 to your computer and use it in GitHub Desktop.
Save bmac/f9a73141522b687c99192e4f56fe9648 to your computer and use it in GitHub Desktop.
New Twiddle
import Adapter from "ember-data/adapters/rest";
export default Adapter.extend({
host: 'https://localhost:5432'
});
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
export default Model.extend({
name: DS.attr('string'),
books: DS.hasMany('book', { async: false }),
booksAttr: DS.attr()
});
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
export default Model.extend({
title: DS.attr('string'),
author: DS.belongsTo('author', { async: false })
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.get('store').findAll('author')
.then(console.log.bind(console))
.catch((error) => {
console.log('in catch', error);
throw error;
});
}
});
import Serializer from "ember-data/serializers/rest";
export default Serializer.extend();
message: {{model.message}}
<pre>
{{model.stack}}
</pre>
<h2>My Library</h2>
<hr>
{{outlet}}
{{#each model as |author| }}
<section>
<h3>{{author.name}}</h3>
<h5>{{author.booksAttr}}</h5>
<ul>
{{#each author.books as |book|}}
<li>{{book.title}}</li>
{{/each}}
</ul>
</section>
{{/each}}
{
"version": "0.10.4",
"EmberENV": {
"FEATURES": {
}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "release",
"ember-data": "canary",
"ember-template-compiler": "release",
"route-recognizer": "https://rawgit.com/tildeio/route-recognizer/56f5fcec6ae58d8e86b5dc77609809fb91198142/dist/route-recognizer.js",
"FakeXMLHttpRequest": "https://rawgit.com/pretenderjs/FakeXMLHttpRequest/23c3a96b5b24f1bfe595867437e4f128a29c2840/fake_xml_http_request.js",
"pretender": "https://rawgit.com/pretenderjs/pretender/c6de9afe18b1472aded2592f5a80ad9a26a0e262/pretender.js"
},
"addons": {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment