# ActiveRecord::AssociationTypeMismatch

**URL:** <https://discuss.rubyonrails.org/t/activerecord-associationtypemismatch/39687>\
**Category:** rubyonrails-talk\
**Created:** [February 23, 2009, 6:34am UTC](https://discuss.rubyonrails.org/t/activerecord-associationtypemismatch/39687 "2009-02-23T06:34:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Habgood](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@Chris\_Habgood](https://discuss.rubyonrails.org/u/Chris_Habgood)\
**Post date:** [February 23, 2009, 6:34am UTC](https://discuss.rubyonrails.org/t/activerecord-associationtypemismatch/39687/1 "2009-02-23T06:34:07Z")

</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| &nbsp;&nbsp;&nbsp;&nbsp;@mop.contacts \<\< contact end

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

It is giving me the above error. Any ideas?

---

<div class="post-metadata">

**Author:** ![Chris\_Habgood](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@Chris\_Habgood](https://discuss.rubyonrails.org/u/Chris_Habgood)\
**Post date:** [February 23, 2009, 7:16am UTC](https://discuss.rubyonrails.org/t/activerecord-associationtypemismatch/39687/2 "2009-02-23T07:16:44Z")

</div>

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