1

最新の ember.js にアップグレードしました。その直後、私のアプリは失敗し始めました。

Firebug の出力は次のとおりです。

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

関連するコードは次のとおりです。

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();
    }
});

新しいバージョンで何が変わったのかわかりません。

4

1 に答える 1

5

Ember Data の最新バージョン (ベータ 2 以降) では、代わりApp.Clock.find()this.get('store').find('clock').

Ember Data Beta Transitionのドキュメントをお読みください。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 に答える