Skip to content

Commit

Permalink
Singleton resources can now have nested resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
olalonde committed Oct 4, 2012
1 parent 832f869 commit c8353c2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/railway_routes.js
Expand Up @@ -228,7 +228,11 @@ Map.prototype.resources = function (name, params, actions) {
var activeRoutes = getActiveRoutes(params);
// but first, create subroutes
if (typeof actions == 'function') {
this.subroutes(name + '/:' + (singularize(name) || name) + '_id', actions);
// if Resource is a singleton, we don't need to append /:resource_id
if(params.singleton_for)
this.subroutes(name + '/', actions);
else
this.subroutes(name + '/:' + (singularize(name) || name) + '_id', actions);
}
// now let's walk through action routes
for (var action in activeRoutes) {
Expand Down

0 comments on commit c8353c2

Please sign in to comment.