This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.TodosController = Ember.ArrayController.extend({ | |
actions: { | |
createTodo: function () { | |
// Get the todo title set by the "New Todo" text field | |
var title = this.get('newTitle'); | |
if (!title.trim()) { return; } | |
// Create the new Todo model | |
var todo = this.store.createRecord( App.Todo, { | |
title: title, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Todo = require('../models/todo'); | |
exports.index = function(req, res) { | |
Todo.find(function(err, todos) { | |
res.send({ | |
todos: todos | |
}); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var mongoose = require('mongoose'); | |
var path = require('path'); | |
var app = express(); | |
mongoose.set('debug', true); | |
mongoose.connect('mongodb://127.0.0.1/express_ember_example'); | |
app.set('port', process.env.PORT || 3333); | |
app.use(express.logger('dev')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var todos = require('./controllers/todos'); | |
module.exports = function(app) { | |
app.get('/api/1/todos', todos.index); | |
app.post('/api/1/todos', todos.create); | |
app.put('/api/1/todos/:id', todos.update); | |
app.del('/api/1/todos/:id', todos.destroy); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
var todoSchema = new mongoose.Schema({ | |
title: { type: String, required: true }, | |
is_completed: Boolean | |
}); | |
module.exports = mongoose.model('Todo', todoSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var mongoose = require('mongoose'); | |
var path = require('path'); | |
var app = express(); | |
mongoose.set('debug', true); | |
// This is the location of your mongo server, as well as the db name. | |
mongoose.connect('mongodb://127.0.0.1/express_ember_example'); | |
app.set('port', process.env.PORT || 3333); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Router.map(function() { | |
return this.resource('todos', { | |
path: '/' | |
}, function() {}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DS.RESTAdapter.reopen({ | |
namespace: 'api/1', | |
serializer: DS.RESTSerializer.extend({ | |
primaryKey: function(type) { | |
return '_id'; | |
} | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.App = Ember.Application.create(); | |
require('store'); | |
require('router'); | |
var folderOrder = [ 'routes', 'models', 'views', 'controllers', 'helpers', | |
'templates', 'components' ]; | |
folderOrder.forEach(function(folder) { | |
window.require.list().filter(function(module) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.config = | |
# See http://brunch.io/#documentation for docs. | |
files: | |
javascripts: | |
joinTo: 'app.js': /^(app|vendor|bower_components)/ | |
order: | |
before: [ | |
'bower_components/jquery/jquery.js' | |
'bower_components/handlebars/handlebars.js' | |
'bower_components/ember/ember.js' |