I am trying to implement BackboneRelational and keep getting
"Cannot instantiate more than one Backbone.RelationalModel with the same id per type!"
class App.Models.User extends Backbone.RelationalModel
urlRoot : '/api/users'
idAttribute: 'id'
relations: [
type: Backbone.HasMany
key: 'plots'
relatedModel: 'App.Models.Plot'
collectionType: 'App.Collections.Plots'
includeInJSON: false
reverseRelation:
key: 'user_id',
includeInJSON: 'id'
]
class App.Models.Plot extends Backbone.RelationalModel
urlRoot : '/api/plots'
idAttribute: 'id'
If I switch one of the models to extends Backbone.Model I can instantiate both, but I get all the warnings that the relational functionality is broken..
I am trying to achieve the following:
plot = new App.Models.Plot({id : 700})
plot.fetch()
plot.get('user')
What am I missing?