0
我有2个输入字段从2个不同的散列产生。我怎样才能有2个循环显示彼此之间的信息
table_head = {"key1"=>"thead1", "key2"=>"thead2", "key3"=>"thead3", "key4"=>"thead4"}
table_content = {"1"=>"column1", "2"=>"column2", "3"=>"column3", "4"=>"column4"}
<%= form_for([@category, @page], url: update_pages_path) do |f| %>
<% @page.table_head.each_with_index do |(key, value), i| %>
<%= text_field_tag ('header[' + i.to_s + ']'), value %>
<% end%>
<% @page.table_content.each_with_index do |(key, value), i| %>
<%= select_tag 'content[' + i.to_s + ']', options_for_select(@category_keys, value), { :multiple => true, :size => 3} %>
<% end%>
<% end %>
这使得4个table_head
输入和4种table_content
选择。但我需要他们来订购,表头输入,然后表格内容选择,然后表头输入,内容选择等等。不是所有的表头输入,然后所有的表格内容选择。
我能为这些字段
<% @page.table_head.each_with_index do |(key, value), i| %>
<%= text_field_tag ('header[' + i.to_s + ']'), value %>
<%= select_tag 'content[' + i.to_s + ']', options_for_select(@category_keys), { :multiple => true, :size => 3} %>
<% end%>
但随后默认options_for_select
value
不能放在了内容领域做到这一点。
我怎么能有场订购头,内容头,内容等。团长,团长,团长,团长,内容,内容等的INSEAD ..
我将如何应用此表格? – Rob
像这样@ user3234020 – nickcen
从字面上来看,它更具体一些,并问我如何使用'.zip'来单独访问每个散列值而不是整个散列。我会给你最新的答案。 – Rob