Skip to content

Instantly share code, notes, and snippets.

@xpressivecode
Last active December 24, 2015 14:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xpressivecode/6813565 to your computer and use it in GitHub Desktop.
Save xpressivecode/6813565 to your computer and use it in GitHub Desktop.
Sample for routing resources using IronRouter
IronRouter.prototype.mapResource = function(resource){
var router = this;
var _routes = [
{ name: resource, path: '/' + resource, action: 'index' },
{ name: 'show' + resource, path: '/' + resource + '/:id', action: 'show' }
];
_.each(_routes, function(route, index){
router.map(function(){
this.route(route.name, {
path: route.path,
controller: resource + 'Controller',
action: route.action
});
});
});
};
//usage Router.mapResource('item');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment