Skip to content

Instantly share code, notes, and snippets.

@sgonyea
Created September 9, 2013 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgonyea/6500439 to your computer and use it in GitHub Desktop.
Save sgonyea/6500439 to your computer and use it in GitHub Desktop.
/*global Ember*/
/*global Todos*/
// For more information see: http://emberjs.com/guides/routing/
Todos.Router.map(function () {
this.resource('todos', { path: '/' }, function () {
this.route('active');
this.route('completed');
});
});
Todos.TodosRoute = Ember.Route.extend({
model: function () {
return this.store.find('todo');
}
});
Todos.TodosIndexRoute = Ember.Route.extend({
model: function () {
return this.modelFor('todos');
}
});
Todos.TodosActiveRoute = Ember.Route.extend({
model: function () {
return Todos.Todo.filter(function (todo) {
return !todo.get('isCompleted');
});
},
renderTemplate: function (controller) {
this.render('todos/index', {controller:controller});
}
});
Todos.TodosCompletedRoute = Ember.Route.extend({
model: function () {
return Todos.Todo.filter(function (todo) {
return todo.get('isCompleted');
});
},
renderTemplate: function (controller) {
this.render('todos/index', {controller:controller});
}
});
// for more details see: http://emberjs.com/guides/models/defining-models/
Todos.Todo = DS.Model.extend({
title: DS.attr('string'),
isCompleted: DS.attr('boolean')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment