When to use a (nested) route?

Hi,

I’m completely new to emberjs and my only experience with it so far is reading the emberjs in Action MEAP Book. Currently the routes are giving me a hard time. It seems like I simply don’t get the idea.

I was thinking to develop a tasking application to wrap my head around emberjs. I was thinking about something a little more complex than the basic todo-list apps i see all around the web.

So for example lets take somethink like JIRA.

  • You have a dashboard with open tasks for different projects and differnet releases.
  • Then you have on the left a list of projects with the possibility to create a new one at the top (simple input with button)
  • When you select a project you see all the tasks belonging to it with the possibility to assign them to a specific release
  • a List of possible releases is displayed on the left
  • you can create new tasks

So how would the applications architecture look for this? What kind of routes would you use to design something like that? As I see there is the main-application route for the layout, a projects route and controller for the projects a nested tasks resource in the projects and also a nested release resource in the projects.

Or is it a better way to load all the projects in the main-application route? Where should i load all the dashboard items?

It would be really nice if someone could help me with my confusion. I can’t find much stuff about the right use of emberjs routes in the web.

Thanks

I think a structure like this would be appropriate:

'index' -> resource '/'
    'projects' -> resource '/projects'
        'project' -> route '/:project_id'
        'new' -> route '/new'
    'tasks' -> resource '/tasks'
        'task' -> route '/:task_id'
        'new' -> route '/new'
    'releases' -> resource '/releases'
        'release' -> route '/:release_id'
        'new' -> route '/new'

Note that you don’t have to explicitly define the index resource (Ember does this automatically), I just listed it to make the hierarchy more clear. Also, when creating the ‘new’ routes, you don’t have to explicitly declare a path, as Ember will automatically pick the name of the route as the path unless you tell it otherwise.

Then in the models you’d interrelate the various pieces of data, etc.

Hope that helps!

(Update: forgot about the other ‘new’ routes. :-))