Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added some documentation about singleton resources in README.md

  • Loading branch information...
commit 832f8692bd47eb2b634fb93bad57e34855f693cb 1 parent bd89625
@olalonde olalonde authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 README.md
View
20 README.md
@@ -58,6 +58,26 @@ In that case your handler should be:
http://railwayjs.com/routing.html
+### Singleton resources
+
+To create a singleton resource, set the singleton_for property of the
+params hash to the resource you want the singleton resource to map to.
+
+Example usage:
+
+ map.resources('users');
+ map.resources('account', {
+ singleton_for: 'users',
+ middleware: function(req, res, next) {
+ // Set the id parameter since we don't get it from the URL
+ // like is usually the case for normal resources.
+ if(req.user)
+ req.params.id = req.user.id;
+ else
+ return res.redirect('/login');
+ next();
+ }});
+
## Example app
Check out [example app][1] to deal with middleware, route handling, and generic routes:
Please sign in to comment.
Something went wrong with that request. Please try again.