Emberjs-用夹具运行ember-data返回DS.Store没有方法'create'

时间:2012-11-22 14:23:12

标签: ember.js ember-data

fiddle 会返回以下错误:

**UnTypeError: Object <DS.Store:ember270> has no method 'create'**

小提琴中的代码粘贴在

下面
 App = Ember.Application.create();

  App.ApplicationController  = Em.Controller.extend({ });

  App.Store = DS.Store.create({
   revision: 7,
   adapter: DS.FixtureAdapter.create()
  });

 //models
 App.Account = DS.Model.extend({
   name: DS.attr('string'),
   user: DS.hasMany('App.User'),
   project: DS.hasMany('App.Project')   
 });


App.User = DS.Model.extend({
  name: DS.attr('string'),
  email: DS.attr('string'),
  password: DS.attr('string'),
  isSelected: DS.attr('boolean',{defaultValue: false }),
  isAdmin: DS.attr('boolean',{defaultValue: false }),
  isOwner: DS.attr('boolean',{defaultValue: false }),                     
  account: DS.belongsTo('App.Account'),
  project: DS.hasMany('App.Project')   
});


App.Project = DS.Model.extend({
 name: DS.attr('string'),
 account: DS.belongsTo('App.Account'),
 user: DS.belongsTo('App.User')   
});

//fixtures for the models

App.Account.FIXTURES = [
 {
    "id": 1,
    "name": "United-shoes"
 },

 {
    "id": 2,
    "name": "Boosters"
 }
];

App.User.FIXTURES = [
  {
    "id": 1,
    "name": 'James',
    "email": 'Denis',
    "password": 'abc',
    "isAdmin": true,
    "account_id": 1
  },

  {
    "id": 2,
    "name": 'mile',
    "email": 'terrence',
    "password": '123',
    "account_id": 2
  }    
 ];

 App.Project.FIXTURES = [
   {
    "id": 1,
    "name": "Increase market share",
   "user_id": 1,
   "account_id": 1
   },

  {
    "id": 2,
    "name": "optimise customers funnel capture",
    "user_id": 2,
    "account_id": 2
  }

];

//ember-data stuff ends

App.ApplicationView = Em.View.extend({
 templateName: 'application'       
});

App.ApplicationView = Ember.View.extend({
   templateName:  'application'
});

App.AccountController = Ember.ArrayProxy.extend({

});

App.AccountView = Ember.View.extend({
 templateName: 'account'  
});

App.UserController = Ember.ArrayProxy.extend({
 // content: 

});

App.UserView = Ember.View.extend({
 templateName: 'user'  
});

App.ProjectController = Ember.ArrayProxy.extend({

});

App.ProjectView = Ember.View.extend({
 templateName: 'project'  
});


App.Router = Em.Router.extend({
  enableLogging: true,
  location: 'history',
  root: Em.Route.extend({
     route: '/',
     index: Em.Route.extend({
       route: '/',
       connectOutlets: function(router) {
         router.get('applicationController').connectOutlet(
  'account');
        router.get('applicationController').connectOutlet(
  'user', App.Store.findAll(App.User));              
      }            
    }),               

    account: Em.Route.extend({
      route: '/account',

        index: Em.Route.extend({
            route: '/'
        })
    }),

    user: Em.Route.extend({
      route: '/user',

        index: Em.Route.extend({
            route: '/'
        })
    }),

    project: Em.Route.extend({
      route: '/project',

        index: Em.Route.extend({
            route: '/'
        })
    })

  }) 
});​

2 个答案:

答案 0 :(得分:2)

DS.Store实例App.Store重命名为App.store

小提琴:http://jsfiddle.net/egKAH/2/

我认为App.Store是保留的

答案 1 :(得分:1)

这不再是真的。 http://emberjs.com/api/data/classes/DS.Store.html

App.Store是正确的。