Relationship insert problem

Tim Perrett <rails-mailing-list@...> writes:

Interstingly...

    if request.post?       address = CustomerAddress.new(params[:delivery])       unless address.save! # <-- Record sucseeds validation, and insertes a record in DB          <at> customer = Customer.new(params[:customer])          <at> customer.customer_addresses = address # <-- this is the problem line where the 'each' exception is comming from.         begin            <at> customer.save!         rescue => <at> error           flash[:notice] = 'Could not be saved.'         end       else         flash[:notice] = 'address not valid in model'       end     end

for a has_one: customer.customer_address = address

for a has_many: customer.customer_addresses << address

where << is usually used to append something (address) to something else (customer.customer_addresses)

Gareth