coffeescript - ember-cli - Ember Data get request failed TypeError - undefined is not a function -
i'm porting ember portion of ember-rails app ember cli. far good, i'm having problem request that's blowing in restserializer.
the application controller attempts grab list of widgets
`import ember 'ember'` applicationcontroller = ember.controller.extend widgets: (-> @store.find('unfinishedwidgets', id: @get('currentid')) ).property() `export default applicationcontroller`
i can see api request fire off, json comes back, looks did in ember rails stack. except instead of updating property , displaying in view, blows up:
typeerror: undefined not function @ object.func (http://localhost:4200/myapp/assets/vendor.js:49473:18) @ object.cache.get (http://localhost:4200/myapp/assets/vendor.js:25091:38) @ decamelize (http://localhost:4200/myapp/assets/vendor.js:49515:31) @ restserializer.extend.keyforattribute (http://localhost:4200/myapp/assets/vendor.js:66565:16) @ apply (http://localhost:4200/myapp/assets/vendor.js:32821:27) @ superwrapper [as keyforattribute] (http://localhost:4200/myapp/assets/vendor.js:32393:15) @ null.<anonymous> (http://localhost:4200/myapp/assets/vendor.js:69024:31) @ null.<anonymous> (http://localhost:4200/myapp/assets/vendor.js:71513:20) @ cb (http://localhost:4200/myapp/assets/vendor.js:29067:22) @ orderedset.foreach (http://localhost:4200/myapp/assets/vendor.js:28865:13) vendor.js:28532logtoconsole vendor.js:28532rsvp.onerrordefault vendor.js:42608__exports__.default.trigger vendor.js:61072promise._onerror vendor.js:62084publishrejection vendor.js:60315(anonymous function) vendor.js:42583deferredactionqueues.invoke vendor.js:13853deferredactionqueues.flush vendor.js:13923backburner.end vendor.js:13309backburner.run vendor.js:13364run vendor.js:31375hash.success vendor.js:68006fire vendor.js:3237self.firewith vendor.js:3349done vendor.js:9393callback
i set in breakpoint @ decamelize, stopped inspect going on:
function decamelize(str) { homecoming decamelize_cache.get(str); }
str @ point isn't string, it's:
object {type: undefined, isattribute: true, options: object, parenttype: function, name: "bundleid"} isattribute: true name: "otherid" options: object parenttype: (subclass of ds.model) type: undefined__proto__: object
so first ds.attr() in model:
`import ds 'ember-data'` unfinishedwidgets = ds.model.extend otherid: ds.attr() # other attrs `export default unsubmittedrequest`
i'm using activemodeladapter default, , i've made empty activemodelserializer.
`import ds 'ember-data'` applicationadapter = ds.activemodeladapter.extend namespace: 'api/myapp/v1' `export default applicationadapter` `import ds 'ember-data'` applicationserializer = ds.activemodelserializer.extend() `export default applicationserializer`
edit:
i ended fixing with:
applicationserializer = ds.activemodelserializer.extend keyforattribute: (type, name) -> name
though i'm still not clear on why necessary in ember cli when fine in ember-rails
this happens when server returns invalid json response. in case it's not returning root object.
you're server returning this
{ other_id: 1 // ... }
and needs be
{ unfinished_widget: { other_id: 1 // ... } }
the activemodeladapter/serializer expects in style. error terrible , should reported bug in ember-data. i've nail before , it's super hard debug , track down.
coffeescript ember-data ember-cli
No comments:
Post a Comment