Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamBrodzinski/7636784 to your computer and use it in GitHub Desktop.
Save AdamBrodzinski/7636784 to your computer and use it in GitHub Desktop.
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