Browse files

Added check if user exists on show action for controller scaffolding

  • Loading branch information...
1 parent 4d0fee7 commit 3db16df650365adc218bc7f1e859885801f6d61e @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
@@ -42,7 +42,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 %>.toObj()});
+ 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 %>.toObj()});
+ }
});
};

0 comments on commit 3db16df

Please sign in to comment.