Shopify/batman — Issue #309: Association foreign key undefined in URL
Author: jaehess
Created: 2012-01-17 18:01:35+00:00
State: open

In a simple association

```coffeescript
class Post extends Batman.Model
@hasMany 'comments'
class Comment extends Batman.Model
@belongsTo 'post'
```

When I try to create a comment for a given post, (I am expecting something like /posts/1/comments for a rails backend) I get /posts/undefined/comments

Controller code

```coffeescript
class Example.CommentsController extends Batman.Controller
create: (params) ->
post = Example.Post.find(1)
comment = new Example.Comment
comment.set('post', post)
comment.save()
```
I checked in the test specs and this seems to be the proper pattern for setting the association.