Next is not defined, but I don't understand how to define it in my function
The problem is here:
module.exports = {
// you had err here instead of next as last argument
'new':function(req, res, next){
Student.findOne({_id:req.param('takes')}, function foundStudent (err, student){
if (err) return next(err);
if (!student) return next();
res.view({
student: student
});
});
},
create: function(req,res,next){
Course.create(req.params.all(), function courseCreated (err, course){
if(err) next(err);
res.json(course)
});
}
};
I think you need to change the definition for the function new
to:
'new':function(req, res, next){