Vote count:
0
The User can create contacts and each contact can have many addresses.
In the first view the user create a contact with an address
In the second view, the user select the contact and the latest address used is loaded
The view
<%= form_for @cart do |f| %>
<%= render '/shared/msg_or_errors', :f=>@cart%>
<%= f.select :delivery_type_id, DeliveryType.all.collect {|b| [b.name, b.id]}%>
<%= f.fields_for :user_contact do |uc| %>
<%= uc.text_field :first_name%>
<%= uc.text_field :last_name%>
<%= uc.country_select :country_id %>
<%= uc.text_field :email%>
<%= uc.fields_for :addresses do |uca| %>
<%= uca.text_field :street1 %>
<%= uca.country_select :country_id %>
<%end%>
<% end %>
<%= f.text_field :msg%>
<%= f.submit "Send"%>
Based on that code how can I create a new address if it is new or just save the relation in case is not new?
asked 36 secs ago
Rails nested form, how to save when selecting
Aucun commentaire:
Enregistrer un commentaire