3

ember アプリ キット内でネストされたリソースを定義しようとしています。私のファイル構造は間違っていますか? ネストされたリソースを追加すると、次の例外が発生します。

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

ネストされた「ページ」リソースを定義する関数をコメント アウトするだけで、アプリが正しく読み込まれ、ページ テンプレートが表示されます。

ルーターコード:

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;

したがって、ファイル構造は次のとおりです。

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

./pages:
index.js    page.js

ページ ルート:

export default Ember.Route.extend({

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

});

ページ/インデックス ルート:

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

pages/index ルートの es6 生成モジュールは次のようになります。

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

1 に答える 1