Uh oh... I wrote that example so if it doesn't work, I'm to blame :)
Just to be sure, did you call App1.run()
at the beginning of that script? I ran into that issue while testing last week -- gotta call run
to load associations!
Edit:
Oh, it looks like a matter of using the API just right. You have to be explicit with the #{label}_type
and #{label}_id
of the related models. Batman.js will load the associations from JSON just fine, but you'll have to specify them when initializing a new record, for example:
super_strength = new App1.Superpower
name: "Super Strength"
superpowerable_id: superman.get('id'),
superpowerable_type: 'Hero'
I put up a JSFiddle where it's working: http://jsfiddle.net/2atLZ/2/
I'll go back to the docs and add a note about this! Long term, would be great if the API just accepted #{label}
then extracted #{label}_id
and #{label}_type
... but for now, it's not so.!