# Form creates multiple models - handling errors

**URL:** <https://www.ruby-forum.com/t/form-creates-multiple-models-handling-errors/161822>\
**Category:** Rails\
**Created:** [March 2, 2009, 9:03pm UTC](https://www.ruby-forum.com/t/form-creates-multiple-models-handling-errors/161822 "2009-03-02T21:03:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![psujohn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@psujohn](https://www.ruby-forum.com/u/psujohn)\
**Post date:** [March 2, 2009, 9:03pm UTC](https://www.ruby-forum.com/t/form-creates-multiple-models-handling-errors/161822/1 "2009-03-02T21:03:53Z")

</div>

Ok I’m sure I could find the answer to this if I knew the correct  
terminology but anyway …

So I have a form to create a new vendor. A vendor has\_many services  
through services\_vendors.

The new view has a couple “collection\_select :service, i” and the  
controller does:  
@vendor.services\_vendors \<\< ServicesVendor.new()

which all works great unless you make an error filling out the form  
and then you get sent back to the form where rails handily fills out  
all the fields except for the services dropdowns.

Now from what I was reading I need an instance variable for the  
service to “remember” it’s setting but I’m not sure what to set, how  
to set it or what to set it to.
