Permalink
Browse files

docs for (req, id, callback) sig

  • Loading branch information...
1 parent edbb4d4 commit 1b4b59d20ead6ddabaffd1a740b0d8409102db96 @tj tj committed Sep 8, 2011
Showing with 6 additions and 0 deletions.
  1. +6 −0 Readme.md
View
@@ -84,7 +84,13 @@ Resources have the concept of "auto-loading" associated data. For example we can
User.load = function(id, fn) {
fn(null, users[id]);
};
+
+ // or
+ User.load = function(req, id, fn) {
+ fn(null, users[id]);
+ };
+
app.resource('users', { show: ..., load: User.load });
With the auto-loader defined, the `req.user` object will be available now be available to the actions automatically. We may pass the "load" option as the third param as well, although this is equivalent to above, but allows you to either export ".load" along with your actions, or passing it explicitly:

0 comments on commit 1b4b59d

Please sign in to comment.