Ember Application Suite and Resource Routes

I am trying to define a nested resource in an ember application suite. Is my file structure incorrect? When I add a nested resource, I get the following exception:

Error: Assertion Failed: The URL '/pages.index' did not match any routes in your application

Just commenting on the function that defines the embedded resource of the "page", the application loads correctly and displays the page template.

Router Code:

var Router = Ember.Router.extend(); 

Router.map(function() {
  this.route('component-test');
  this.route('helper-test');
  this.resource('pages', {path: '/pages'}
      // if this line is commented out, no error (index route is not called though)
      , function() { this.resource('page', {path: ':page_id'}); }
    );
});

export default Router;

The file structure is as follows:

$ ls -R
component-test.js   helper-test.js      pages
component_test.js   index.js        pages.js

./pages:
index.js    page.js

Page Route:

export default Ember.Route.extend({

  model: function() {
    return [{title: "One", _id: "one"}, {title: "Two", _id: "two"}];
    //this.store.find('page');
  }

});

pages / index route:

export default Ember.Route.extend({
  model: function() {
    return this.modelFor('page');
  }
});

The generated es6 module for the pages / index route is as follows:

define("appkit/routes/pages/index", 
  ["exports"],
  function(__exports__) {
    "use strict";
    __exports__["default"] = Ember.Route.extend({
      model: function() {
        return this.modelFor('page');
      }
    });
  });
+3
source share
1 answer

Try it.

Do you have an index route for pages named "index.js" in the folder folder?

Ember App Kit . , "app/routes/pages/index.js".

https://github.com/kiwiupover/for_eric

var Router = Ember.Router.extend(); 

Router.map(function() {
  this.route('component-test');
  this.route('helper-test');
  this.resource('pages', function() {
    this.route('new');
  });
});

export default Router;

routes -|        //folder
   pages.js     
   pages -|      // folder
     index.js

export default Ember.Route.extend({
  model: function(){
    return [{title: "One", _id: "one"}, {title: "Two", _id: "two"}];
  }
});

export default Ember.Route.extend({
  model: function(){
    return this.modelFor('pages');
  }
});

templates -|     //folder
   pages.hbs     
   pages -|      // folder
     index.hbs

<h1>Pages</h1>
<ul>
  {{#each}}
    <li>{{title}}</li>
  {{/each}}
</ul>

{{outlet}}

<h2>The Index page for Pages</h2>

<ul>
  {{#each}}
    <li>the index page {{title}}</li>
  {{/each}}
</ul>
+4

All Articles