我的Ember应用无法识别FirebaseAdapter

时间:2015-03-10 02:14:16

标签: ember.js ember-data firebase emberfire

我尝试在我的Ember应用中使用Firebase。我安装了Emberfire,但我的应用程序返回

  

未捕获的TypeError:无法读取属性'延伸'未定义的

因为它没有阅读“FirebaseAdapter”

App.ApplicationAdapter = DS.FirebaseAdapter.extend({
    firebase: new Firebase('https://glowing-fire-number.firebaseio.com/')
});

我检查了在Firebase和EmberFire之前是否正在加载Ember数据。这是我的脚本参考:

<!-- script references -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="http://maps.googleapis.com/maps/api/js?sensor=false&extension=.js&output=embed"></script>
    <script src="js/scripts.js"></script>

<script src="js/libs/jquery-1.11.2.min.js"></script> 
<script src="js/libs/handlebars-v1.3.0.js"></script>
<script src="js/libs/ember.js"></script>
<script src="js/libs/moment.js"></script>
<script src="http://builds.emberjs.com/tags/v1.0.0-beta.12/ember-data.js"></script>

<script src="js/app.js"></script>
<script src="vendor/list-view.js"></script>
<script src="js/controller.js"></script>

<script src="https://cdn.firebase.com/js/client/2.2.2/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/emberfire/1.3.3/emberfire.min.js"></script>

和我的App.js

App = Ember.Application.create();

App.Router.map(function() {
  // put your routes here
  this.resource('stacks')
  this.resource('stack', {path: ':stack_id'}, function() {
        this.route('edit');
    }); 
    this.route('create');
  });


App.IndexRoute = Ember.Route.extend({
  beforeModel: function() {
    this.transitionTo('stacks');
  }
});

App.StacksRoute = Ember.Route.extend({
    model: function() {
        return this.store.findAll('stack');
    }
});

App.StackRoute = Ember.Route.extend({
    model: function(params) {
        return stacks.findBy('id', params.stack_id);
    }
});

Ember.Handlebars.helper('format-date', function(date) {
    return moment(date).fromNow();
});


App.CreateRoute = Ember.Route.extend({

});


//EmberFire stuff

App.ApplicationAdapter = DS.FirebaseAdapter.extend({
    firebase: new Firebase('https://glowing-fire-2514.firebaseio.com/')
});

App.Stack = DS.Model.extend({
  title: DS.attr('string'),
  location: DS.attr('string'),
  date: DS.attr('number'),
  details: DS.attr('string')
});

有什么想法吗?感谢您的帮助!

1 个答案:

答案 0 :(得分:4)

在包含EmberFire之后,您似乎需要包含app.js。在this.resource('stacks')之后路由器中还有一个缺少分号,但我认为这不会导致错误。

我们刚刚发布了一些更新,使得使用EmberFire作为ember-cli插件更加容易,我建议您查看它。详细信息如下:https://www.firebase.com/blog/2015-03-09-new-emberfire-features.html