# ActiveRecord::AssociationTypeMismatch

**URL:** <https://www.ruby-forum.com/t/activerecord-associationtypemismatch/161073>\
**Category:** Rails\
**Created:** [February 23, 2009, 7:34am UTC](https://www.ruby-forum.com/t/activerecord-associationtypemismatch/161073 "2009-02-23T07:34:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [February 23, 2009, 7:34am UTC](https://www.ruby-forum.com/t/activerecord-associationtypemismatch/161073/1 "2009-02-23T07:34:38Z")

</div>

I have 2 models:

mop, has\_and\_belong\_to\_many :contacts  
contact, has\_and\_belong\_to\_many :mops

when I save my mop Ii have the users coming in a an array:  
[“9”,10"]

I am doing this to asscociate each one to a mop:

@contacts.each do |contact|  
@mop.contacts \<\< contact  
end

Contact(#44950470) expected, got String(#20837400)

It is giving me the above error. Any ideas?

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [February 23, 2009, 8:17am UTC](https://www.ruby-forum.com/t/activerecord-associationtypemismatch/161073/2 "2009-02-23T08:17:23Z")

</div>

Never mind. I looked at Ryan B. complex forms example for the  
100th time and got it to work using his method. SWEET.
