I am getting this error. ActiveRecord::AssociationTypeMismatch in Resources#create Focus expected, got String I have a select menu named resource[focus]. My focus (belongs_to :resources) table has a one-to-many relationship with the resources (has_one :focus) table (A resource will have only one focus but one focus will have many resources). I assume this error means that the focus is looking for a string (I am sending an integer, focus_id). What do I do? Thanks. Seth Buntin
on 2006-02-21 16:20
on 2006-02-21 16:50
Okay. I figured out that my relationship association was messed up (resources: belongs_to :focus and focus: has_many :resources) but I still get the same error.
on 2006-02-21 16:52
Seth Buntin - KATE wrote: > Okay. I figured out that my relationship association was messed up > (resources: belongs_to :focus and focus: has_many :resources) but I > still get the same error. I decided to see what would happen if I used the console and here is what I found out. I start the console: # ruby script/console # resource = Resource.new() .... # resource.focus = 1 THEN I GET THE ERROR: Focus Expected, got Fixnum If I put resource.focus = '1' or "1" I get. Focus Expected, got String. What is it wanting?
on 2006-02-21 20:42
On 21/02/06, Seth Buntin - KATE <firstname.lastname@example.org> wrote: > # ruby script/console > > What is it wanting? It simply wants Focus :) Try: # resource.focus = Focus.new and this: # resource.focus_id = 1 Use resource[focus_id] in view.