UNPKG

905 BMarkdownView Raw
1Routes are added in the function exported from ./app/routes.js.
2
3This function takes two arguments route and resource which are also functions.
4
5Declaring a route will add a single route to your application and requires you to provide the path as the first argument as well as the method and action in an options hash as the second argument. This function should only be used for defining custom routes.
6
7Declaring a resource will add all CRUD routes for a controller to your application. The resource function only takes one argument and that is the name of the resource.
8
9```javascript
10export default function routes() {
11 this.resource('posts');
12 this.resource('users', function () {
13 // GET /users/custom-route => UsersController#customRoute
14 this.get('custom-route');
15 // GET /users/custom-route => UsersController#myCustomAction
16 this.get('custom-route', 'myCustomAction');
17 });
18}
19```