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