Self-referential HABTM SQL mal-formed when updating record


Anyone ever had this kind of problem with ActiveScaffold?

Cheers, Sazima

What steps will reproduce the problem?

  1. Create self-referential HABTM application (like the common “user
    has friends” example)

  2. Try to add more than 1 friend to a given user using ActiveScaffold.

What is the expected output? What do you see instead?
2+ friends related to the user. Instead I get a MySQL error:

ActiveRecord::StatementInvalid (Mysql::Error: Duplicate entry ‘4’ for
1: INSERT INTO friends (updated_at, id, user_id, created_at,
friend_id) VALUES (‘2008-01-22 20:27:49’, 4, 2, ‘2008-01-22
20:26:31’, 4))

What version (or revision) of the product are you using?
1.1.1 + Rails 2.0.2 (InstantRails 2 installation)

friend_id is a key (ie it must be unique)

this is a DB schema error. not a rails error.
Just remove the key definition around that column