1

I'm using ember-data:

// 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");      
});

Using a namespace:

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

The Ember model:

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

The route looks like this:

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
  }
});

Here is the data:

{
  "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"
  }]
}
jdcravens
  • 577
  • 1
  • 4
  • 15

1 Answers1

3

I am using ember-tools to manage the project build. The issue is with ember-tools default build placing the Model definition after the Route. UPDATED: This is because I manually created the Article model without using a generator. (I've since used the generator and the order is created correctly)

I've fixed it by manually updated the built: application.js from this:

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')
});

to this:

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');
  }
});

I resolved this by inspecting a working app, and found that within the JSONSerializer applyTransforms() type was referencing a different type:

enter image description here

It should be the namespace model Class like this:

enter image description here

jdcravens
  • 577
  • 1
  • 4
  • 15