Routing folder structure for CRUD in ember CLI

I’m using Ember CLI with EmberScript and Emblem. Very nice.

I have this set of simple CRUD routes:

Router.map ->
  @resource "users", ->
    @route "new"
    @resource "user", { path: ':id' }, ->
      @route "edit"

Unfortunately, in my routes folder, I end up with this:

routes
|--- user
|    |--- edit.em
|--- users
|    |--- index.em
|    |--- new.em
|--- user.em

Frankly, this is awful. I want all my routes for the User model to be in one users folder, not scattered throughout my routes folder. With a couple dozen models, this is going to be a mess! Is there any way to set this up so that I can have something, say, like this:

|--- users
|    |--- edit.em
|    |--- index.em
|    |--- new.em
|    |--- show.em

I haven’t been able to find any documentation explaining how to do this. Is it possible? Got a link?

TIA.

Chas.

1 Like

Sorry to reply immediately to my own post, but with a student I figured out how to do this:

Router.map ->
  @resource "users", ->
    @route "index", { path: ''        }
    @route "new",   { path: 'new'     }
    @route "show",  { path: ':id'     }
    @route "edit",  { path: ':id/edit'}

Is there any problem with doing it this way?

1 Like

did that work for you? i am currently having the same problem.

I tried what you suggested but it keeps complaining about not being able to find the correct templates.

i am using ember cli 0.0.28

Thanks.