1

I just upgraded to the latest ember.js. Right after that, my app started to fail.

Here is the Firebug output:

DEBUG: -------------------------------
DEBUG: Ember      : 1.0.0
DEBUG: Ember Data : 1.0.0-beta.2
DEBUG: Handlebars : 1.0.0
DEBUG: jQuery     : 1.10.2
DEBUG: -------------------------------

Attempting URL transition to /
Transition #1: Beginning validation for transition to clocks.index
Transition #1: application: calling beforeModel hook
Transition #1: application: resolving model
Transition #1: application: calling afterModel hook
Transition #1: application: validation succeeded, proceeding
Transition #1: clocks: calling beforeModel hook
Transition #1: clocks: resolving model
Transition #1: clocks.index: transition was aborted
Transition #1: clocks: handling error: TypeError: App.Clock.find is not a function
Error while loading route:
TypeError: App.Clock.find is not a function 
    return App.Clock.find();
TypeError: App.Clock.find is not a function 
    return App.Clock.find();
TypeError: App.Clock.createRecord is not a function

Here is the relevant code:

App.ClocksRoute = Ember.Route.extend({
  model: function() {
    var locationService = UtilitiesHelper.LocationService.getInstance();
    locationService.getLocation(function(location) {
            App.Clock.createRecord({
                city: location.city,
                country: location.country,
                latitude: location.latitude,
                longitude: location.longitude,
                color: '#483D8B',
                order: -10
            });
        });

        return App.Clock.find();
    }
});

I am not able to figure out what has changed in the new version.

4

1 回答 1

5

在最新版本的 Ember Data(Beta 2 及更高版本)中,App.Clock.find()您将不得不这样做this.get('store').find('clock')

请通读Ember Data Beta 转换文档find在第一节中介绍。

您还需要将您的更新createRecord为:

  this.get('store').createRecord('clock', {
     city: location.city,
     country: location.country,
     latitude: location.latitude,
     longitude: location.longitude,
     color: '#483D8B',
     order: -10
  });

尽管这些可能不是您将代码迁移到最新版本所需进行的唯一更改。这篇文章也可能会有所帮助。

于 2013-09-22T19:24:46.243 回答