Skip to content

Instantly share code, notes, and snippets.

@tgsoverly
Last active December 17, 2015 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgsoverly/5558558 to your computer and use it in GitHub Desktop.
Save tgsoverly/5558558 to your computer and use it in GitHub Desktop.
EmberJS nested routes, resources and templates when you use separate files with the rails-gem

The Issue

You are using the rails gem and you have a Router:

App.Router.map ->
  @resource "things", ()->
    @resource("thing", path: ":thing_id", ()->
      @route "create"

You want to make templates for "things", "thing" and "thing/create", but you are using seperate files and don't know where and how they should be structured.

The answer

Rule of thumb: resources are not nested, but routes are. Meaning you put all the the templates associated with "resources" at the top level and the rest in the resource it routes to's folder:

./things.hbs
./thing.hbs
./thing/create.hbs

This applies no matter how far into the nested chain you would go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment