Ember newbie routing questions (best practice)


Hi, I’ve followed Ember for a while now and decided to give it a try myself finally.

I was planning on doing a little project management application. One scenario is that there are some customers and projects. A project has a relationship to a customer. Also more projects can be created for one customer.

I think it is very straight forward to have the following routes:

/customers /* to display a list of customers */
/customers/:customer_id /* to display a single customer */
/customers/new /* to create a new customer */
/customers/:customer_id/edit /* to edit a customer */

As I want to have projects separated from the customers (to have some seperate lists independend from customers), i was planning to implement the following routes for projects:

/projects /* to display a list of projects */
/projects/:project_id /* to display a single project */
/projects/:project_id/edit /* to edit a project */

Now my questions:

  • For listing all projects related to one customer, should I implement a route like /customers/:customer_id/projects or should I link from the customer template to /projects with a filter for the project list to only display the projects in relation to the desired customer?

  • Similarly for adding projects to a customer, should I implement a route /customers/:customer_id/projects/new or link to /projects/new with a binding or query parameter for the desired customer to automatically create the relationship without the user having to specify the customer for the project.

I thought that I saw a YouTube video about best practices in Ember from a conference and the guy mentioned that you should use as much individual routes as possible and only nest really obvious routes which make sense. I can’t remember which video it was though.

Perhaps any of you guys could give me a hint in the right direction with the routes. I would really appreciate it.