How to create form for new User model wi开发者_运维知识库th embedded Phone model? I've found solution for creating form to add Phone for existing User but how to do that at the same time i create new User?
You have to create a nested form
<%= form_for @user, :url => users_path do |f| %>
<%= f.label :name, "Name:" %> <br />
<%= f.text_field :name %>
<%= f.fields_for :phone do |p| %>
<%= p.label :number, "Phone Number" %> <br />
<%= p.text_field :number %>
<% end %>
<% end %>
精彩评论