Forms with multiple parameters

Hi,

I have a customer form in which I allow the customer to enter multiple
addresses. The customer has a one to many relationship with an address.
What is the proper way of allowing for multiple parameters within the
view. ie. is there a way to link the customer to the address within the
form, so that everything can be submitted in one hash. I am currently
doing it the following way:

(for example)

<%= text_field ‘customer’, ‘name’, html_options = {‘style’,
‘width:328px;’} %>
<%= text_field ‘customer’, ‘phone’, html_options = {‘style’,
‘width:328px;’} %>
<%= text_field ‘address_1’, ‘street’, html_options = {‘style’,
‘width:328px;’} %>
<%= text_field ‘address_1’, ‘city’, html_options = {‘style’,
‘width:328px;’} %>
<%= text_field ‘address_2’, ‘street’, html_options = {‘style’,
‘width:328px;’} %>
<%= text_field ‘address_2’, ‘city’, html_options = {‘style’,
‘width:328px;’} %>

I then assign each address to the customer in the controller update
method.

The problem I am having with doing it this way is with the error
checking. If there is a problem with the submision, only the customer
is posted back to the view, and therefor all of the address are left
blank.

Thanks for your help!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs