1602/railway-routes — pull request #7 by olalonde (2012-10-04 08:32:36+00:00)
Title: Added singleton resources functionality

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();
}});

This will create the following routes:

GET /account users#show
POST /account users#create
GET /account/new users#new
GET /account/edit users#edit
DELETE /account users#destroy
PUT /account users#update