我有一个创建地址的表格,这个地址有一个坐标数组。但我不知道生成输入以键入例如 3 个坐标。可以是 n 个坐标,我打算用 jQuery(创建输入)来做到这一点。但现在我想显示现有坐标。
这是代码:
模型
class Address
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Spacial::Document
field :street, :type => String
field :number, :type => Integer
field :phone, :type => String
field :delivery_zone, :type => Array
end
erb.html
<%= form_for [:owner, :company,@address], :html => {:class => "form-horizontal"} do |f| %>
<%= @address.delivery_zone.each do |dz|%>
<% fields_for 'delivery_zone[]' , dz do |items| -%>
?? I don't know what to write here!!
<% end %>
<% end %>
<%end%>
我正在寻找的是为字段delivery_zone
和数组中的每个项目生成如下内容:
<input id="address_delivery_zone[]" name="address[delivery_zone][]" type="text" value="32.7 33.8" />