Fixed error when committing a created record #48

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
5 participants

kyptin commented Jan 17, 2012

When creating a record and calling commit on the store, I get the following error:

Uncaught TypeError: Object (subclass of DS.State) has no method 'enter'

Here is some code that exhibits this error:

window.App = Ember.Application.create();

App.store = DS.Store.create({
  adapter: DS.Adapter.create({
    createRecord: function() {
      console.log('created record');
    }
  }),
});

App.Person = DS.Model.extend({
  name:       DS.attr('string'),
});

App.store.createRecord(App.Person, {name: 'Jeff T.'});
App.store.commit();

The problem was that we were attempting to enter a state class, rather than a state instance. This was caused by calling DS.State.extend() within another DS.State.extend() call.

kyptin added some commits Jan 17, 2012

@kyptin kyptin Fixed error when committing a created record:
When creating a record and calling commit on the store, I get the
following error:

    Uncaught TypeError: Object (subclass of DS.State) has no method 'enter'

Here is some code that exhibits this error:

    window.App = Ember.Application.create();

    App.store = DS.Store.create({
      adapter: DS.Adapter.create({
        createRecord: function() {
          console.log('created record');
        }
      }),
    });

    App.Person = DS.Model.extend({
      name:       DS.attr('string'),
    });

    App.store.createRecord(App.Person, {name: 'Jeff T.'});
    App.store.commit();

The problem was that we were attempting to enter a state class, rather
than a state instance.  This was caused by calling `DS.State.extend()`
within another `DS.State.extend()` call.
61ec184
@kyptin kyptin Merge branch 'master' of github.com:emberjs/data 094a252
Contributor

dmathieu commented Jan 26, 2012

+1, this definitely fixes the problem. Thanks @kyptin

rvega commented Jan 26, 2012

This works for me as well +1

kyptin commented Jan 26, 2012

Glad to hear it, dmathieu and rvega; thanks for speaking up. :-)

mimay commented Jan 27, 2012

Fix works ok for me as well!

Owner

tomdale commented Feb 14, 2012

@kyptin This actually seems like a bug in Ember's state manager, which I think we fixed here: emberjs/ember.js@df0c49a. Can you test to see if the issue is resolved after updating to that version of Ember.js?

kyptin commented Feb 15, 2012

@tomdale Thanks for the response. I can confirm that this is no longer an issue on the latest HEAD's of emberjs/ember and emberjs/data. So I'm going to close the issue now.

The funny thing is, when I started bisecting to try to nail down which commit fixed the issue, it was not your commit but commit 68ded658b1baa1801effd2094ac526b014609372 (merged in commit 8dbf37df517764fe129029d04a056bd38f4cfd4d), from January 6—which is actually a week or two before I created this issue. The same commit fixed the issue both for the current HEAD of emberjs/data as well as for the commit from which I originally forked (7a3a349). Apparently I wasn't running the latest emberjs/ember code when I found this issue. Whoops!

kyptin closed this Feb 15, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment