Search code examples
ember.jsember-cli

How to implement my product resource into a Pods structure?


Reading http://www.ember-cli.com/#pod-structure

Lets say I have a product resource. Which currently has the following directory structure:

app/controllers/products/base.js
app/controllers/products/edit.js
app/controllers/products/new.js
app/controllers/products/index.js

With pods all the logic in these files are put in a single file app/products/controller.js?

At the same time, my routes and templates for these resources currently look like:

app/routes/products/base.js
app/routes/products/edit.js
app/routes/products/new.js
app/routes/products/index.js
app/templates/products/-form.hbs
app/templates/products/edit.hbs
app/templates/products/index.hbs
app/templates/products/new.hbs
app/templates/products/show.hbs

How should this be converted to Pods?


Solution

  • You can use ember generate --pod --dry-run to help with that:

    $ ember g -p -d route products/base
    version: 0.1.6
    The option '--dryRun' is not supported by the generate command. Run `ember generate --help` for a list of supported options.
    installing
    You specified the dry-run flag, so no changes will be written.
      create app/products/base/route.js
      create app/products/base/template.hbs
    installing
    You specified the dry-run flag, so no changes will be written.
      create tests/unit/products/base/route-test.js
    $
    

    (I don't know why it complains yet it honours the option, might be a bug).

    So you'd end up with a structure like:

    app/controllers/products/base/route.js
    app/controllers/products/edit/route.js
    

    etc.