Ember App Kit with ember data

笑着哭i 提交于 2019-12-05 10:37:50

Your Account model is using the DS.RESTAdapter instead of the DS.FixtureAdapter, because you are setting the adapter in ApplicationAdapter, the expected is AccountAdapter. So you receive an error from the ajax, probably because the url does not match a server.

To configure the DS.FixtureAdapter per model use:

var AccountAdapter = DS.FixtureAdapter.extend();
export default AccountAdapter; 

Or as global adapter for all models:

App.Store = DS.Store.extend({
    adapter: DS.FixtureAdapter
});

I hope it helps

I think the real issue was that you defined your Fixture Adapter in adapters/adapter.js.

When you called:

store.find('account');

It correctly found the model but then looked for the correct adapter. You don't have an adapters/account.js so it used the application default, which has been mentioned is a RESTAdapter.

To get your example working, just change the filename.

I was getting the same error...

However I was able to fix this by importing my ApplicationAdapter, and using that to define my store:

app/adapters/application.js:

var ApplicationAdapter = DS.FixtureAdapter.extend();

export default ApplicationAdapter;

app/store/application.js:

import ApplicationAdapter from 'appkit/adapters/application';
var Store = DS.Store.extend({
    adapter: ApplicationAdapter
});

export default Store;

Keep in mind I have not changed the default application name away from appkit yet, you may have to change this name or the paths to make this function properly for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!