Skip to content

Instantly share code, notes, and snippets.

@ruohki
Created June 13, 2016 22:49
Show Gist options
  • Save ruohki/48bf02c75995f17c9187cfdb3fd55df9 to your computer and use it in GitHub Desktop.
Save ruohki/48bf02c75995f17c9187cfdb3fd55df9 to your computer and use it in GitHub Desktop.
problem
//app/adapters/application.js
import JSONAPIAdapter from 'ember-data/adapters/json-api';
export default JSONAPIAdapter.extend({
namespace: 'api',
host: 'https://community-ruohki.c9users.io'
});
//app/controllers/task.js
import Ember from 'ember';
export default Ember.Controller.extend({
model: function(params) {
console.log("fetching task...");
this.store.findRecord('task', 1).then(function(task) {
return task;
});
}
});
//app/models/task.js
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'),
description: attr('string'),
date: attr('date'),
created: attr('string', {
defaultValue: function() {
return new Date();
}
})
});
//app/templates/task.hbs
<h1>Tasks</h1>
{{outlet}}
{{#each model as |item|}}
{{item.content}}
{{/each}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment