Reputation: 3055
How can I define routes like this:
I currently have this configured:
@resource 'users', path: '/users/:user_id', ->
@route 'projects'
But the problem is that I can't access /users
(there's no such route). The UsersIndexRoute
is referring to /users/:user_id
.
Upvotes: 0
Views: 602
Reputation: 1804
You would be best doing something like:
this.resource('users', function() {
this.resource('user', {path: '/:user_id'}, function() {
this.resource('projects');
});
});
This will generate (or if you've defined them; use):
UsersRoute
with URL /users
, a UsersController
and a User
model where you would load all users.UserRoute
with URL /users/:user_id
, a UserController
and the same User
model where you would load an individual user's details.ProjectsRoute
with URL /users/:user_id/projects
, a ProjectsController
and a Project
model where you would load the user projects.JSBin example showing this in action.
See here for more information on defining routes and what Ember will expect to see (or generate for you).
Upvotes: 1