Ember - ember.debug.js:19746错误:无法创建'适配器的实例:application'

时间:2016-09-07 21:11:56

标签: ruby-on-rails ember.js ember-data ember-rails

我正在构建一个ember应用程序并尝试连接到rails API,从问题终点读取数据。

这是两个独立的应用程序。

我的代码如下:

适配器/ application.js中

import DS from 'ember-data';
import ActiveModelAdapter from 'active-model-adapter';

export default DS.ActiveModelAdapter.extend({
  host: 'http://localhost:3000/api/v2'
});

模型/ questions.js

import DS from 'ember-data';

export default DS.Model.extend({
  text:  DS.attr('string'),
  title: DS.attr('string'),
  debateTopicId:  DS.attr('string'),
  releaseAt: DS.attr('date'),
  expiresAt:  DS.attr('date')
});

路由/ questions.js

import Ember from 'ember';

export default Ember.Route.extend({
  model: function() {
    return this.store.findAll('question');
  }
});

模板/ questions.hbs

<h2>This is the Questions Feed</h2>

{{#each model as |question|}}
  <h3>{{question.id}} - {{question.text}}</h3>
{{/each}}

我试图呼吁的终点是:

http://localhost:3000/api/v2/questions

我收到错误:

ember.debug.js:19746 Error: Failed to create an instance of 'adapter:application'. Most likely an improperly defined class or an invalid module export.
    at instantiate (ember.debug.js:1477)
    at lookup (ember.debug.js:1336)
    at Object.lookup (ember.debug.js:1255)
    at Class.lookup (ember.debug.js:34526)
    at ContainerInstanceCache.instanceFor (container-instance-cache.js:62)
    at ContainerInstanceCache._findInstance (container-instance-cache.js:51)
    at ContainerInstanceCache.get (container-instance-cache.js:39)
    at Class.retrieveManagedInstance (store.js:2105)
    at Class.lookupAdapter (store.js:2111)
    at Class.adapterFor (store.js:2051)

任何想法是什么问题?

0 个答案:

没有答案