Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 连接到Express/Mongoose后端的余烬数据被拒绝;对象没有方法';每个变压器属性'&引用;_Ember.js_Ember Data_Ember Tools - Fatal编程技术网

Ember.js 连接到Express/Mongoose后端的余烬数据被拒绝;对象没有方法';每个变压器属性'&引用;

Ember.js 连接到Express/Mongoose后端的余烬数据被拒绝;对象没有方法';每个变压器属性'&引用;,ember.js,ember-data,ember-tools,Ember.js,Ember Data,Ember Tools,我正在使用余烬数据: // Version: v1.0.0-beta.3-2-ga01195b // Last commit: a01195b (2013-10-01 19:41:06 -0700) var App = Ember.Application.create(); App.Router.map(function() { this.resource("main"); }); 使用命名空间: App.ApplicationAdapter = DS.RESTAdapter

我正在使用余烬数据:

// Version: v1.0.0-beta.3-2-ga01195b
// Last commit: a01195b (2013-10-01 19:41:06 -0700)

var App = Ember.Application.create();
App.Router.map(function() {
  this.resource("main");      
});
使用命名空间:

App.ApplicationAdapter = DS.RESTAdapter.extend({
  namespace: 'api'
});
余烬模型:

App.Article = DS.Model.extend({
  title: DS.attr('string'),
  desc: DS.attr('string')
});
路线如下所示:

App.MainRoute = Ember.Route.extend({
  model: function() {
    console.log(this.store.find('article')); // isRejected: true, reason: Object has no method 'eachTransformedAttribute'
    this.store.find('article').then(function(results){console.log(results)}); //nothing
  }
});
以下是数据:

{
  "articles": [{
    "_id": "5266057ee074693175000001",
    "__v": 0,
    "createdAt": "2013-10-22T04:56:30.631Z",
    "desc": "testing, testing",
    "title": "Basic",
    "id": "5266057ee074693175000001"
  }, {
    "_id": "5266057ee074693175000002",
    "__v": 0,
    "createdAt": "2013-10-22T04:56:30.636Z",
    "desc": "testing, testing",
    "title": "Basic2",
    "id": "5266057ee074693175000002"
  }, {
    "_id": "5266057ee074693175000003",
    "__v": 0,
    "createdAt": "2013-10-22T04:56:30.636Z",
    "desc": "testing, testing",
    "title": "Basic3",
    "id": "5266057ee074693175000003"
  }, {
    "_id": "5266057ee074693175000004",
    "__v": 0,
    "createdAt": "2013-10-22T04:56:30.636Z",
    "desc": "testing, testing",
    "title": "Basic4",
    "id": "5266057ee074693175000004"
  }]
}
我正在使用来管理项目构建。 问题在于ember工具的默认生成将模型定义放置在管线之后。 更新:这是因为我在没有使用生成器的情况下手动创建了文章模型。(此后我使用了生成器,订单创建正确)

我已通过以下方式手动更新build:application.js修复了此问题:

App.MainRoute = Ember.Route.extend({
  model: function() {
    return this.store.find('document');
  }
});

App.Article = DS.Model.extend({
  title: DS.attr('string'),
  file: DS.attr('string')
});
为此:

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

App.MainRoute = Ember.Route.extend({
  model: function() {
    return this.store.find('document');
  }
});
我通过检查一个正在工作的应用程序解决了这个问题,发现在JSONSerializer applyTransforms()中,类型引用了一个不同的类型:

它应该是名称空间模型类,如下所示:

App.MainRoute = Ember.Route.extend({
  model: function() {
    console.log(this.store.find('article')); // isRejected: true, reason: Object has no method 'eachTransformedAttribute'
    this.store.find('article').then(function(results){console.log(results)}); //nothing
  }
});

您使用的是什么版本的余烬数据?刚刚更新了上面的余烬数据版本。