Question

I'm attempting to create an ember transaction to commit a single model to the backend api.

Coffeescript:

comic = App.Comic.createRecord(title: @get('comicTitle'))
transaction = comic.get('store').transaction
transaction.add(comic)
transaction.commit()

Which gives the javascript error:

Uncaught TypeError: Object function () {
    return DS.Transaction.create({ store: this });
  } has no method 'add'

I've googled various different ways to use ember transactions, but I'm not sure where I'm going wrong. I'm using the latest version of ember data.

Était-ce utile?

La solution

The coffeescript to js translation may not be happening correctly. Try changing to

transaction = @get('store').transaction()

I have found the implicit method invocation in coffeescript trips up in Ember occasionally.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top