0

我想要循环中的问题ID

<div class = "y">
 <% @slno = 0 %>
 <%- @answers.each do |b| -%>
   <% @slno= @slno + 1 %>
  <div class = "label_field_pair">
      <label for "questions">
          <%= @slno %> ) <%= b.ques %>
      </label>  <br>
    <div class = "label_field_pair2">
      <label for "options">
        <%= radio_button_tag "question#{b.id}", "#{b.id}ans1"%><%= b.ans1  %>
        <%= radio_button_tag "question#{b.id}", "#{b.id}ans2"%><%= b.ans2  %>
        <%= radio_button_tag "question#{b.id}", "#{b.id}ans3"%><%= b.ans3  %>
        <%= radio_button_tag "question#{b.id}", "#{b.id}ans4"%><%= b.ans4  %>
      </label>
    </div>
  </div>
 <% end %>
<div id = "submit_button">
<%= submit_tag "", :value => "Submit" %>
</div>
</div>

在这里它显示了问题......我想要每个问题的ID分别

4

1 回答 1

0

我不知道我是否理解你想要做什么,但你可以尝试这样的事情:

  <label for "options">
    <% (1..4).each do |answer_id|
      <%= radio_button_tag "question#{b.id}", "#{b.id}ans#{answer_id}"%><%= b.send("ans#{answer_id}")  %>
    <% end %>
  </label>
于 2013-10-05T18:12:09.143 回答