2013-04-13 39 views
5

Tôi đang sử dụng DS.FixtureAdapter và không thể nhận được các mục liên quan đến sử dụng DS.belongsToDS.FixtureAdapter có hỗ trợ sideload không?

App.User = DS.Model.extend({ 
    login: DS.attr('string'), 
    profile: DS.belongsTo('App.Profile') 
}); 

App.Profile = DS.Model.extend({ 
    fullname: DS.attr('string'), 
    address: DS.attr('string'), 
    user: DS.belongsTo('App.User') 
}); 

App.Router.map(function() { 
    this.resource('user', { path: ':user_id' }); 
}); 

App.UserRoute = Ember.Route.extend({ 
    model: function(params) { 
    return App.User.find(params.user_id) 
    } 
}); 

Là nó chỉ một tính năng của phần còn lại Adapter?

cập nhật

Các dữ liệu cố định là một cái gì đó như thế này:

một cái gì đó như thế này:

App.User.FIXTURES = [ 
    { 
     id: 1, 
     login: "marlus", 
     profile: 1 
    } 
]; 

App.Profile.FIXTURES = [ 
    { 
     id: 1, 
     fullname: "Marlus Araujo", 
     address: "Rio", 
     user: 1 
    } 
]; 
+0

Nó có sẵn trong FixtureAdapter, dữ liệu lịch thi đấu của bạn trông như thế nào? –

+0

Có vẻ như nó sẽ hoạt động. Lưu ý rằng bộ chuyển đổi đồ đạc không có đồ đạc "mong muốn tải", vì vậy bạn phải tính đến vòng lặp chạy khi bạn truy cập vào liên kết. –

+0

Tôi đã thử nghiệm (Ember RC6) nó tuyên bố Store như sau: 'App.Store = DS.Store.extend ({ adapter: DS.FixtureAdapter }); ' Và nó hoạt động tốt. – fabriciotav

Trả lời

1

Phiên bản mới nhất của dữ liệu Ember (1.0.0-beta4), có cú pháp mới để định cấu hình mô hình với bộ điều hợp lịch thi đấu.

App.UserAdapter = DS.FixtureAdapter.extend(); 

App.User.FIXTURES = [{ 
    id: 1, firstName: 'Bob', lastName: 'Roberts' 
}]; 

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

App.UserRoute = Ember.Route.extend({ 
    model: function() { 
     return this.store.find('user', params.user_id); 
    } 
});