spine / spine

Lightweight MVC library for building JavaScript applications
http://spine.github.io
MIT License
3.66k stars 426 forks source link

Relation requires declaration of _id column #199

Closed pehrlich closed 12 years ago

pehrlich commented 12 years ago

Contrary to the docs, I appear to have to declare specifically columns for relationships http://spinejs.com/docs/relations

class window.Post extends Spine.Model
  @configure 'Post',
      'body'
  @belongsTo 'goal', 'Goal'

p = Goal.first().posts().create({body: 'asd'})
p.body # 'asd'
p.goal_id # undefined (as well as goal())

class window.Post extends Spine.Model
  @configure 'Post',
      'body',
      'goal_id'
  @belongsTo 'goal', 'Goal'

p = Goal.first().posts().create({body: 'asd'})
p.goal_id # 17
p.goal() @ goal
maccman commented 12 years ago

Have a look at the Models attributes - goal_id should be in there. This looks like a separate issue.