jeudi 20 août 2015

Ember cli app with different adapter types?

I have an ember cli app (v1.10) that uses a restadapter in the adapter/application.js. I'm adding several sections to the app but the services are not written yet and I want to use fixtures with faux data in them to build everything out. In my first attempt, I cannot seem to integrate sections with different an adapter type different than the one in application.js. According to the console error, the app when I go to #/assessments keeps trying to make an api call even though the assessments adapter is using FixtureAdapter. Is this a common problem/ limitation in ember cli?

router.js

Router.map(function() {
    this.resource('assessments', function() {
        this.route('publish');        
    });
});

models/assessments.js--

import DS from 'ember-data';


var Assessments = DS.Model.extend({
    clientId: DS.attr(),
    clientName: DS.attr('string'),
    envId: DS.attr(),
    envName: DS.attr('string')
});

Assessments.reopenClass({
    FIXTURES: [
        {   
            id: 1,
            clientId: 1,
            clientName: 'a',
            envId:10,
            envName: 'Production'
        },
        {
            id: 2,
            clientId: 2,
            clientName: 'b',
            envId:11,
            envName: 'Dev'
        },
        {
            id: 3,
            clientId: 1,
            clientName: 'a',
            envId:12,
            envName: 'Lab'
        } 
    ]
});

export default Assessments;

routes/assessments.js

import Ember from 'ember';

export default Ember.Route.extend({

    model: function(){
        return this.store.find('assessments');
    }
});

Any assistance is much appreciated!

adapters/assessments.js

import DS from "ember-data";

export default DS.FixtureAdapter.extend({});




Aucun commentaire:

Enregistrer un commentaire