AssociationTypeMismatch

I have a very simple pairing scenario that links a pair to two items (cross-comparison and rating).

My problem is that on insertion of the pair I get an AssociationTypeMismatch error, that I haven't seen before.

class Pair < ActiveRecord::Base   has_one :flag   has_one :item_1, :class_name => 'Item'   has_one :item_2, :class_name => 'Item' end

class Flag < ActiveRecord::Base   belongs_to :pair   has_many :pairs   validates_presence_of :descriptor, :weight end

The Item class is very simple.

What am I missing or doing wrong on trying to create the new pair?

pair = Pair.new(:item_1 => 606276291, :item_2 => 977772386) ActiveRecord::AssociationTypeMismatch: Item(#70065549615160) expected, got Fixnum(#70065601288820)

Thanks.

class Pair < ActiveRecord::Base   belongs_to :flag

  belongs_to :item, :class_name => 'Item', :foreign_key => 'item_1', :validate => true   belongs_to :item, :class_name => 'Item', :foreign_key => 'item_2', :validate => true

end

seems to fix the problem.

What am I missing or doing wrong on trying to create the new pair?

pair = Pair.new(:item_1 => 606276291, :item_2 => 977772386) ActiveRecord::AssociationTypeMismatch: Item(#70065549615160) expected, got Fixnum(#70065601288820)

It's expecting an instance of item, but you're giving it an integer instead.

Fred