Ember.js Ember Direct URL findQuery返回整个存储,而不是单个记录

Ember.js Ember Direct URL findQuery返回整个存储,而不是单个记录,ember.js,ember-data,Ember.js,Ember Data,这应该很简单,但我很挣扎。找到下面的帖子,让我的查询顺利运行 从链接导航到时工作。但是,根据上面的帖子,直接访问时返回的模型应该是单个记录数组。然后我应该能够返回数组的第一个对象。但是我的整个商店都被退回了。所有子类别。slug在每个记录上都是唯一的,因此它应该只返回一个子类别。所有数据和关系都是根据“余烬检查器数据”选项卡加载的,在那里显示所有数据和关系 下面是代码的JSBin 错误:断言失败:ArrayProxy需要数组或Ember.ArrayProxy,但您传递了对象 这是我的路线代码:

这应该很简单,但我很挣扎。找到下面的帖子,让我的查询顺利运行

从链接导航到时工作。但是,根据上面的帖子,直接访问时返回的模型应该是单个记录数组。然后我应该能够返回数组的第一个对象。但是我的整个商店都被退回了。所有子类别。slug在每个记录上都是唯一的,因此它应该只返回一个子类别。所有数据和关系都是根据“余烬检查器数据”选项卡加载的,在那里显示所有数据和关系

下面是代码的JSBin

错误:断言失败:ArrayProxy需要数组或Ember.ArrayProxy,但您传递了对象

这是我的路线代码:

App.Router.map(function () {    
      this.resource("section");
      this.resource('subcategory', { path: "/section/:slug" }, function () {       
          this.resource("record", { path: ":id" });
       });
}); 


App.SectionRoute = Ember.Route.extend({
    model: function (params) {
        Ember.Logger.warn("Inside section route");       
        return this.store.find('subcategory'); // gets all subcategories perfectly      
    },
    setupController: function (controller, model) {
        this.controller.set('model', model);
        this.controllerFor('sectionnav').set('model', model); //set section nav to list of subcats
    }
});


App.SubcategoryRoute = Ember.Route.extend({
     model: function (params) {
         Ember.Logger.warn("Passed Param: " + params.slug);
        return this.store.find('subcategory', { slug: params.slug });
    },
    serialize: function (model) {
        //ANOTHER POSSIBLE ISSUE? THIS IS BEING HIT MULTIPLE TIMES....up to 20 when on PREVIOUS route And 13 times when going to this route directly in url address. THere are 5 subcategories total. With many records.  Why?? 
        Ember.Logger.warn("Serializing in subcategoryroute");
        return { slug: model.get('slug') };
    },  
    setupController: function (controller, model) {
          //If the model comes from a link-to helper it will be an object, if it comes from the route it will be an array of one element
          //model is the entire store rather than the one record when going to the route directly. WHY??
         if (Ember.isArray(model)) {                  
            this.controller.set('model', model.get('firstObject'));            
         } else {
            this.controller.set('model', model); //this works fine from link-to
         }       
        themodel = this.store.find('subcategory');
        this.controllerFor('sectionnav').set('model', themodel);
}
});
以下是嵌入式记录中包含的模型,以防以下原因:

App.Subcategory = DS.Model.extend({
    name: DS.attr('string'),
    slug: DS.attr('string'), 
    records: DS.hasMany('record', { embedded: 'always', async: true })
});
Ember.Inflector.inflector.irregular("subcategory", "subcategories");

App.Record= DS.Model.extend({
    name: DS.attr('string'),
    comments: DS.hasMany('comment', { embedded: 'always', async: true }),
    events: DS.hasMany('event', { embedded: 'always', async: true })
});

 App.Comment = DS.Model.extend({
     title: DS.attr('string')        
 });

 App.Event = DS.Model.extend({
     name: DS.attr('string'),        
     eventdates: DS.hasMany('eventdate', { embedded: 'always' })
 });

 App.Eventdate = DS.Model.extend({  
     eventDate: DS.attr('string'),
     startTime: DS.attr('string')

 });
数据我正在使用RestaAdapter,但以下是Fixture中的子类别数据:

App.Subcategory.FIXTURES = [
    {id: 1, name: "First Category", slug: "firstcategory", records:[1,3]},
    {id: 2, name: "Second Category", slug: "secondcategory", records:[2] },
    {id: 3, name: "Third Category", slug: "thirdcategory", records:[5,6] },
    {id: 4, name: "Fourth Category", slug: "fourthcategory", records:[4] },
    {id: 5, name: "Fifth Category", slug: "fifthcategory", records:[7,8] }
];
App.Record.FIXTURES = [
  {id:1, name: "Record One", comments: [1], events: [1,2]},
  {id:2, name: "Record Two", comments: [2,3], events: []},
  {id:3, name: "Record Three", comments: [4], events: [3]},
  {id:4, name: "Record Four", comments: [], events: []},
  {id:5, name: "Record Five", comments: [6], events: [4]},
  {id:6, name: "Record Six", comments: [], events: []},
  {id:7, name: "Record Seven", comments: [7], events: []},
  {id:8, name: "Record Eight", comments: [], events: []}   
];
App.Comment.FIXTURES = [
  {id:1, name: "Comment One"},
  {id:2, name: "Comment Two"},
  {id:3, name: "Comment Three"},
  {id:4, name: "Comment Four"},
  {id:5, name: "Comment Five"},
  {id:6, name: "Comment Six"},
  {id:7, name: "Comment Seven"},
  {id:8, name: "Record Eight"}  
];

App.Event.FIXTURES = [
  {id:1, name: "Event One", eventDates: [1]},
  {id:2, name: "Event Two",eventDates: [2,3]},
  {id:3, name: "Event Three",eventDates: [4]},
  {id:4, name: "Event Four",eventDates: [5]} 
];

App.Eventdate.FIXTURES = [
  {id:1, eventDate: "4/5/2015", startTime: "07:00"},
  {id:2, eventDate: "6/9/2015", startTime: "08:00"},
  {id:3, eventDate: "5/15/2015", startTime: "15:00"},
  {id:4, eventDate: "3/25/2015", startTime: "14:00"},
  {id:5, eventDate: "4/5/2015", startTime: "11:00"},
];

提前感谢您的帮助。如果需要包含更多信息,请告诉我。

我的Ember调试版本在控制台上为我提供了以下信息:在你的小提琴上

未捕获错误:断言失败:您在id为2的“子类别”上查找了“记录”关系,但未加载某些关联的记录。请确保它们都与父记录一起加载,或者指定关系为async DS.hasMany{async:true}