Skip to content

Instantly share code, notes, and snippets.

@edspencer
Created September 2, 2009 17:39
Show Gist options
  • Save edspencer/179843 to your computer and use it in GitHub Desktop.
Save edspencer/179843 to your computer and use it in GitHub Desktop.
/**
* Defines all routes required for this application
*/
ExtMVC.router.Router.defineRoutes = function(map) {
/**
* Sets up REST-like urls for a given model or models:
*
* map.resources('users');
*
* Is equivalent to:
* map.connect("users", {controller: 'users', action: 'index'}); // #users
* map.connect("users/new", {controller: 'users', action: 'new' }); // #users/new
* map.connect("users/:id/edit/", {controller: 'users', action: 'edit' }); // #users/1/edit
* map.connect("users/:id", {controller: 'users', action: 'show' }); // #users/1
*
* You can pass more than one model to a map.resources call, e.g.:
*
* map.resources('users', 'comments', 'pages', 'products');
*/
//set up default routes
map.connect(":controller/:action");
map.connect(":controller/:action/:id");
//if no url, should a default
map.root({controller: 'index', action: 'index'});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment