Topic: has_many through issues

Hey all,
I have three tables:
groups(id,name)
forums(id,name)
permissions(group_id,forum_id,read_forum,post_replies,post_topics)

# now in script/console I do:

forum=Forum.find_first
group=Group.find_first
perm=Permission.create(:read_forum=>0,:post_replies=>0,:post_topics=>0)
# then when I do:

group.permissions << perm

# I get:

ActiveRecord::StatementInvalid: Mysql::Error: #42S22Unknown column
'id' in 'where clause': UPDATE permissions SET `read_forum` = 0,
`group_id` = 5, `post_replies` = 0, `forum_id` = 5, `post_topics` = 0
WHERE id = 0


any idea what's wrong?

thanx in advance

Pat

Re: has_many through issues

You need to add an id column to the permissions table (it should be primary key and auto incrementing).

Railscasts - Free Ruby on Rails Screencasts