It took some time to track this error, but I finally found out why. I am modeling a card game using the Rails framework. Currently, my database looks (basically) like this:
cards cards_games games
----- ----------- -----
id id id
c_type card_id ...
value game_id other_stuff
And now Rails ActiveRecord card.rb and game.rb look like this
class Card < ActiveRecord::Base
has_and_belongs_to_many :player
has_and_belongs_to_many :game
has_and_belongs_to_many :cardsInPlay, :class_name => "Rule"
end
class Game < ActiveRecord::Base
has_and_belongs_to_many :cards
has_many :players
has_one :rules, :class_name => Rule
end
When I try to start a game and there are several games (more than 1), I get an error
ActiveRecord::StatementInvalid in GameController
Mysql::Error: Duplicate entry '31' for key 1: INSERT INTO `cards_games` (`card_id`, `id`, `game_id`) VALUES (31, 31, 7)
, , cardid == id. , , - , Rails . cardsgames, , card_id id . , , . , "" , cardid gameid . , ( , Rails API , , .. ). "id" INSERT INTO . , , .
, ? - Rails, ? Rails? , , , , - Rail .