Form creates multiple models - handling errors


#1

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.