I'm trying to update my Ember.js app to Ember Data 1.0 Beta. What I have is working with Ember Data 0.14. With the new version I need to manually set typeKey for a model in order for the REST request to have proper path.
I have simple model:
App.Product = DS.Model.extend
name: DS.attr('string')
In Ember Data 1.0 Beta I need to add this in order to get it to work:
App.Product.typeKey = 'product'
Otherwise buildURL method always get passed undefined [buildURL(type.typeKey, …)].
I ran into an issue very similar to this just yesterday. For some reason, I was able to get the typeKey for one of my models, but not the other three. It seemed like some kind of issue with the application not being fully loaded or ready. After the page loaded, I was able to get the typeKey for all four models just fine. See if you can't get the same result. I just had to rearrange a bit of my code to make it work correctly. Hopefully you can do the same.
The problem was caused by using model class instead of its string name in store finder method:
Should be @store.find('product') instead of @store.find(App.Product).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With