简体   繁体   中英

Ember how to use multiple adapters?

I have an ember app that hooks into a rails-api. I am using devise for authentication and have an application.js adapter set up for the authorization. Now I want to connect to my rails DB model and display some data. I need to add the ActiveModelAdapter to connect. How do I add in a second ActiveModelAdapter so I can use it? I'm just getting started with Ember so I wasn't sure.

    import DS from 'ember-data';
    import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
    import ActiveModelAdapter from 'active-model-adapter';

    export default DS.JSONAPIAdapter.extend(DataAdapterMixin, {
      authorizer: 'authorizer:devise'
    });

There is no exact need to create another adapter if you will handle requests at server side the same way. All you really need is to create model which corresponds to payload from server. You will need to create another one adapter only if something differs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM