0
I’m doing a customer registration here to shop and it turns out that some customers have more than 2 phone numbers the system already works with two telephone fields a landline and a mobile phone :
<%= f.label :telcelular , "Tel. Celular" %>
<%= f.telephone_field :telcelular %>
<%= f.label :telfixo , "Tel. Fixo" %>
<%= f.telephone_field :telfixo %>
There is no way I create a field for each phone, since I do not know the amount of phone numbers that each customer has, there is some possibility to save all phones only in one field?
The most correct would be to create a table
telefones
containing a customer reference (cliente_id
). You can put everything in a form using Nested Attributes (1 2 3), but I never tried to use it. The easiest thing is to create a separate form just to add the phones.– user7261
Using Nested Attributes is easy to do. And you can leave in the form a button to go adding fields for phones if necessary. You can take a look at this example http://railscasts.com/episodes/196-nested-model-form-part-1
– Sidney