Browse files

Also add check for existance of the property on edit actions for the …

…controller scaffolding
  • Loading branch information...
1 parent 3db16df commit 3bbb00a10821e342eb933f70276a7bb235622889 @larzconwell larzconwell committed Nov 11, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 templates/scaffold/controller.ejs
View
8 templates/scaffold/controller.ejs
@@ -56,7 +56,13 @@ var <%= names.constructor.plural %> = function () {
var self = this;
geddy.model.<%= names.constructor.singular %>.first(params.id, function(err, <%= names.property.singular %>) {
- self.respond({params: params, <%= names.property.singular %>: <%= names.property.singular %>});
+ if (!<%= names.property.singular %>) {
+ var err = new Error();
+ err.statusCode = 400;
+ self.error(err);
+ } else {
+ self.respond({params: params, <%= names.property.singular %>: <%= names.property.singular %>});
+ }
});
};

0 comments on commit 3bbb00a

Please sign in to comment.