Skip to content

Commit

Permalink
Also add check for existance of the property on edit actions for the …
Browse files Browse the repository at this point in the history
…controller scaffolding
  • Loading branch information
larzconwell committed Nov 11, 2012
1 parent 3db16df commit 3bbb00a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion templates/scaffold/controller.ejs
Expand Up @@ -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 %>});
}
});
};
Expand Down

0 comments on commit 3bbb00a

Please sign in to comment.