Getting AssociationTypeMismatch error when trying to create new object

Hi,

I'm trying to create a model, named "form", which has_many "form_item" objects. The code is

                @form = Form.new(:user_id => session[:user_id],                                  :form_items => params[:form_items])

but I get an error, even though I thought I was passing in the expected form_item ...

ActiveRecord::AssociationTypeMismatch in FormsController#create

FormItem expected, got HashWithIndifferentAccess

Request

Parameters:

{"commit"=>"Submit Form", "form_items"=>[{"description"=>"bbb", "prescription_number"=>"111", "day_supply"=>"20"}]}

Thanks for any input, - Dave

Hi,

I'm trying to create a model, named "form", which has_many "form_item" objects. The code is

               @form = Form.new(:user_id => session[:user_id],                                 :form_items => params[:form_items])

but I get an error, even though I thought I was passing in the expected form_item ...

Same answer as last time you asked: Right now, you're going to have to iterate over params[:form_items]
creating activerecord objects as you go. (Form.new is expecting
form_items to actually be an Array of FormItem objects)

Fred