Reputation: 2197
I have an Ember app using an API which has most of the models implemented, but some of them not, and for those I would like to provide fixtures.
App.ApplicationAdapter = DS.RESTAdapter.extend({
host: 'http://api.com'
});
App.Post = DS.Model.extend({
title: DS.attr(),
body: DS.attr(),
author: DS.attr()
});
// ...
this.store.find('post', 1); // http://api.com/post/1
// ...
App.Tag = DS.Model.extend({
hashtag: DS.attr(),
color: DS.attr()
});
App.Tag.FIXTURES = [
{ hashtag: 'foo', color: '#000' },
{ hashtag: 'bar', color: '#fff' }
]
// ...
this.store.find('tag', 1) // searches among fixtures
Is this possible?
Upvotes: 0
Views: 96
Reputation: 56
You can make adapters specific to models by doing this: App.TagAdapter = DS.FixtureAdapter.extend();
Upvotes: 2
Reputation: 87
How about using a different model with that particular route?
App.TagRoute = Ember.Route.extend({
model: function() {
return [
{ hashtag: 'foo', color: '#000' },
{ hashtag: 'bar', color: '#fff' }
];
}
});
Upvotes: 1