-
-
Save AdamBrodzinski/7636784 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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