I don't understand why I get the following error:

ActiveRecord::AssociationTypeMismatch: User(#29943560) expected, got Fixnum

when I do that in rails console: @game = Game.create(:player => 1060, :played => 1061)

I just want to create a new Game regarding model associations below.

class User < ActiveRecord::Base
    has_many :game_as_player, :class_name => 'Game', :foreign_key => 'player_id'
    has_many :game_as_played, :class_name => 'Game', :foreign_key => 'played_id'
end

class Game < ActiveRecord::Base
    belongs_to :player, :class_name => 'User'
    belongs_to :played, :class_name => 'User'

    attr_accessible :player, :played, :score, :details, :viewed, :read
end

If anyone has an idea... Thanks a lot!

Edit
Report