emberfire icon indicating copy to clipboard operation
emberfire copied to clipboard

Can't destroyRecord (monkeypatch on DS.Store not working)

Open fizz opened this issue 11 years ago • 19 comments

Hi, I get "undefined is not a function" in DS.Model.reopen.deleteRecord. It's trying to call the monkey-patched DS.Store.reopen.recordWillDelete. I see the monkeypatch in the same file, so I have no idea why it's not working.

I'm using ember-cli with Ember 1.10, Ember Data 1.0 beta 15, and EmberFire 1.4.2. But I also tried it with Ember 1.9.1 + Ember Data 1.0 beta 14 and got the exact same result. Am I doing something crazy, or is this in fact broken...?

fizz avatar Mar 16 '15 20:03 fizz

Aha! EmberFire 1.3.3 works! But EmberFire 1.4.0 doesn't.

What I don't get is why the DS.Model monkeypatch works, but the DS.Store monkeypatch just before it in the same initializer file doesn't.

fizz avatar Mar 16 '15 20:03 fizz

that's really odd that the monkey patch fails right after the working one!

Is this using emberfire as an ember-cli addon or included via emberfire.min.js?

Is it possible to reproduce in a JSbin?

tstirrat avatar Mar 16 '15 20:03 tstirrat

Hi @tstirrat, it's the same with ember-cli and without. I made a couple of JSFiddles:

JSFiddle with Ember 1.9.1, EmberData 1.0.0-beta12, EmberFire 1.4.2 (not working): http://jsfiddle.net/8uhtv1ze/

JSFiddle with the same, except for EmberFire 1.3.3 (working): http://jsfiddle.net/s1Lsfp9n/

fizz avatar Mar 16 '15 20:03 fizz

I am guessing that the store object is created and injected before the .reopen() is called thus it has an incorrect prototype..

tstirrat avatar Mar 16 '15 20:03 tstirrat

Still working on this...

tstirrat avatar Mar 18 '15 01:03 tstirrat

Thank you. I wish I had a clue, I'd send a pull request...

fizz avatar Mar 18 '15 01:03 fizz

Will likely do a release tomorrow morning with this fix in it -> #216

tstirrat avatar Mar 18 '15 02:03 tstirrat

Awesome! Thanks.

fizz avatar Mar 18 '15 02:03 fizz

TypeError: this.store.recordWillDelete is not a function I use emberfire v1.4.4

absemetov avatar Apr 13 '15 14:04 absemetov

@absemetov can you please let me know of your ember-data and ember versions?

tstirrat avatar Apr 13 '15 16:04 tstirrat

Ember 1.9.1 Ember Data 1.0.0-beta.16.1 Firebase 2.2.3 EmberFire 1.4.4 Handlebars 2.0.0 jQuery 2.1.3 http://absemetov.koding.io/emberfire.html

absemetov avatar Apr 13 '15 16:04 absemetov

In the example you provided you're using ember-data beta.16.1 and emberfire 1.3.3 which are not compatible (due to ember-data changes). Can you make a minimal test with emberfire 1.4.4 that reproduces the problem?

tstirrat avatar Apr 13 '15 19:04 tstirrat

v1.4.0-1.4.4 TypeError: this.store.recordWillDelete is not a function in line 817

absemetov avatar Apr 14 '15 06:04 absemetov

I just tried this with a new ember-cli project and it cannot reproduce it:

DEBUG: -------------------------------
DEBUG: Ember      : 1.11.1
DEBUG: Ember Data : 1.0.0-beta.16.1
DEBUG: Firebase   : 2.2.4
DEBUG: EmberFire  : 1.4.4
DEBUG: jQuery     : 1.11.2
DEBUG: -------------------------------

Can you please provide a MCVE that reproduces your problem?

tstirrat avatar Apr 14 '15 16:04 tstirrat

I use EmberFire Without Ember CLI https://www.firebase.com/docs/web/libraries/ember/guide.html#section-without-ember-cli

absemetov avatar Apr 14 '15 17:04 absemetov

ok, can you recreate in a jsBin/jsFiddle? this will be like using without ember-cli.

tstirrat avatar Apr 14 '15 17:04 tstirrat

http://jsbin.com/quligo/1/

absemetov avatar Apr 14 '15 17:04 absemetov

@absemetov I was able to reproduce with the non ember-cli usage. I've made a patch for this here: #241

tstirrat avatar Apr 14 '15 20:04 tstirrat

thanks @tstirrat

absemetov avatar Apr 15 '15 04:04 absemetov