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. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Oct 26, 9:43 am, Sem Ptiri <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > 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> > Thanks. > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.