Commit 05b95c6
Changed files (5)
app
tests
unit
models
app/models/cake.js
@@ -3,8 +3,9 @@ import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
description: DS.attr('string'),
- author: DS.belongsTo('user', {async: true}),
- photos: DS.hasMany('photo', {async: true}),
+ category: DS.belongsTo('category'),
+ author: DS.belongsTo('user'),
+ photos: DS.hasMany('photo'),
createdAt: DS.attr('date'),
updatedAt: DS.attr('date'),
app/models/category.js
@@ -0,0 +1,8 @@
+import DS from 'ember-data';
+
+export default DS.Model.extend({
+ name: DS.attr('string'),
+ slug: DS.attr('string'),
+ createdAt: DS.attr('date'),
+ updatedAt: DS.attr('date'),
+});
app/routes/cakes/index.js
@@ -5,11 +5,6 @@ export default Ember.Route.extend(RouteMixin, {
page: 1,
perPage: 12,
model: function(params) {
- params.paramMapping = {
- page: "page",
- perPage: "perPage",
- total_pages: "totalPages"
- };
return this.findPaged('cake', params);
}
});
app/templates/cake.hbs
@@ -6,6 +6,7 @@
<h1>{{#link-to 'cake' this}}{{name}}{{/link-to}}</h1>
<p>By {{author.name}}</p>
<p>{{description}}</p>
+ <p>{{category.name}}</p>
<p>Created at: {{formatted-date createdAt 'MMM Do, YYYY [at] h:mm'}}</p>
<p>Updated at: {{formatted-date updatedAt 'MMM Do, YYYY [at] h:mm'}}</p>
tests/unit/models/category-test.js
@@ -0,0 +1,15 @@
+import {
+ moduleForModel,
+ test
+} from 'ember-qunit';
+
+moduleForModel('category', 'Category', {
+ // Specify the other units that are required for this test.
+ needs: []
+});
+
+test('it exists', function() {
+ var model = this.subject();
+ // var store = this.store();
+ ok(!!model);
+});