Last active
December 24, 2015 14:38
-
-
Save xpressivecode/6813565 to your computer and use it in GitHub Desktop.
Sample for routing resources using IronRouter
This file contains 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