type missmatch - class expected, but got string

hi,i am trying to use ror on a legacy system.

model:

belongs_to :ProvincialTaxAreaCode, class_name: “TaxArea”, foreign_key: “ProvincialTaxAreaCode” #, primary_key: “ProvincialTaxAreaCode”

ProvincialTaxAreaCode is a varchar(20)

html-slect:

test- 123

error:

ActiveRecord::AssociationTypeMismatch (TaxArea(#109333370) expected, got String(#70918210)):

how can i still use the varchar field without converting it???

?? A model "belongs_to" another model, not a string.

This might help:

http://guides.rubyonrails.org/association_basics.html#the-belongs-to-association

where do you see a string?
association is called :ProvincialTaxAreaCode (because of simple_form_for

the associated class is called TaxArea

the fkey is ProvincialTaxAreaCode (varchar20)

where do you see a string?

To repeat quoting you:

model:
   belongs_to :ProvincialTaxAreaCode

ProvincialTaxAreaCode is a varchar(20)

Did you look at the Rails guide link I included?

Hi,

Hi. You should use different names for association and for foreign key for this association. Looks like they are overlapping, just rename association name to fit ar conventions - and it should work.