开发者

How to create Rails3 forms for embedded Mongoid models?

开发者 https://www.devze.com 2023-02-05 07:12 出处:网络
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

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 %>
0

精彩评论

暂无评论...
验证码 换一张
取 消