# ActiveRecord::AssociationTypeMismatch - unsure how to proceed

**URL:** <https://www.ruby-forum.com/t/activerecord-associationtypemismatch-unsure-how-to-proceed/151949>\
**Category:** Rails\
**Created:** [October 28, 2008, 10:35am UTC](https://www.ruby-forum.com/t/activerecord-associationtypemismatch-unsure-how-to-proceed/151949 "2008-10-28T10:35:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lawrence\_Lu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3ec8ea/32.png) [@Lawrence\_Lu](https://www.ruby-forum.com/u/Lawrence_Lu)\
**Post date:** [October 28, 2008, 10:35am UTC](https://www.ruby-forum.com/t/activerecord-associationtypemismatch-unsure-how-to-proceed/151949/1 "2008-10-28T10:35:26Z")

</div>

I’m creating a practice app on RoR, but i’ve run into this problem and  
I’m not sure how to proceed. Basically, its a stock picker, and there  
are Portfolios, Stocks, and Holdings. Holdings belong to both  
Portfolios and a particular Stock.

In my “create holding” page, i’m allowing the user to provide a Stock  
symbol (a string column in the stock table) and a quanity. However,  
for obvious reasons this doesnt work as when the form is submitted,  
this line:

@holding = Holding.new(params[:holding])

Expects the value of “stock” that is passed in to be an actual Stock  
object, not a string representing the symbol for that stock.

How exactly should I get around this without converting the Stock  
field to a dropdown?

Thanks!

---

<div class="post-metadata">

**Author:** ![Lawrence\_Lu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3ec8ea/32.png) [@Lawrence\_Lu](https://www.ruby-forum.com/u/Lawrence_Lu)\
**Post date:** [October 28, 2008, 10:40am UTC](https://www.ruby-forum.com/t/activerecord-associationtypemismatch-unsure-how-to-proceed/151949/2 "2008-10-28T10:40:44Z")

</div>

On 27 Oct 2008, at 22:44, Lawrence Lu wrote:

> @holding = Holding.new(params[:holding])

> Expects the value of “stock” that is passed in to be an actual Stock  
> object, not a string representing the symbol for that stock.

change params[:holding][:stock] before you pass it to Holding.new

Fred
