bug with student update fixed

parent c9b7c9a6
DROP DATABASE symbolstixdb;
GRANT USAGE ON *.* TO 'pictodbuser'@'localhost'; GRANT USAGE ON *.* TO 'pictodbuser'@'localhost';
DROP USER 'pictodbuser'@'localhost'; DROP USER 'pictodbuser'@'localhost';
CREATE USER 'pictodbuser'@'localhost' identified by 'p1KT015'; CREATE USER 'pictodbuser'@'localhost' identified by 'p1KT015';
......
/** /**
* StudentController /* StudentController
* *
* @description :: Server-side logic for managing students * @description :: Server-side logic for managing students
* @help :: See http://links.sailsjs.org/docs/controllers * @help :: See http://links.sailsjs.org/docs/controllers
...@@ -171,6 +171,8 @@ module.exports = { ...@@ -171,6 +171,8 @@ module.exports = {
Student.findOne(req.params.id_stu).exec(function(err, stu){ Student.findOne(req.params.id_stu).exec(function(err, stu){
if (err || !stu) if (err || !stu)
return res.json(500, {error: "No student found"}); return res.json(500, {error: "No student found"});
// copy attributes
for (k in req.body) stu[k] = req.body[k];
stu.save(function(err, saved) { stu.save(function(err, saved) {
if (err) if (err)
return res.json(500, {error: "Error when saving student"}); return res.json(500, {error: "Error when saving student"});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment