Trying to get a hasMany relationship working with Ember but running into an issue
The user json from my REST service includes usertag
{"user":
[{"id":1,"name":"dolores.","email":"kuhlman@stha123n.com",
"usertag":
[{"id":16,"userid":1}]}]}
Everything works fine for retrieving users from the store except when I try include the usertag relationship below
User.rb
App.User = Ember.Model.extend
usertag: DS.hasMany('usertag')
Error while loading route: TypeError: Cannot set property 'store' of undefined
Usertag.rb
App.Usertag = Ember.Model.extend
userid: DS.attr 'string'
Can anyone see where I've made a mistake?
Thanks !
Version info..
Ember : 1.5.1+pre.07fafb84 ember.js?body=1:3524
Ember Data : 1.0.0-beta.7.f87cba88 ember.js?body=1:3524
Handlebars : 1.3.0 ember.js?body=1:3524
jQuery : 1.11.0
Stack:
Error while loading route: TypeError: Cannot set property 'store' of undefined
at Ember.Object.extend.modelFor (http://localhost:3001/assets/ember-data.js?body=1:9815:23)
at Ember.Object.extend.recordForId (http://localhost:3001/assets/ember-data.js?body=1:9268:21)
at deserializeRecordId (http://localhost:3001/assets/ember-data.js?body=1:10199:27)
at deserializeRecordIds (http://localhost:3001/assets/ember-data.js?body=1:10213:9)
at http://localhost:3001/assets/ember-data.js?body=1:10179:11
at http://localhost:3001/assets/ember-data.js?body=1:8520:20
at http://localhost:3001/assets/ember.js?body=1:3431:16
at Object.OrderedSet.forEach (http://localhost:3001/assets/ember.js?body=1:3274:10)
at Object.Map.forEach (http://localhost:3001/assets/ember.js?body=1:3429:10)
at Function.Model.reopenClass.eachRelationship (http://localhost:3001/assets/ember-data.js?body=1:8519:42)
我认为,取决于您的序列化程序,在jSON中,“ usertag”应为“ usertags”。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.