mardi 5 mai 2015

Rails Checkbox formating

Hi I'm trying to build out a survey with a rails app. My rails application has two models: Question has_many :answers and Answer belongs_to :question

I'm trying to iterated through all the questions and all their associated answers and make a checkbox option on all the answers for that associated question. How would I go about making checkboxes? Here's what I have so far. Would this need to be wrapped in a Form for each question too?

 <% @questions.each do |question| %>
  <tr>
    <td><%= question.content %></td><br>
    <% question.answers.each do |answer_choice| %>
         <%= form.check_box :answer_choice %>
    <% end %>
  </tr>
  <% end %>




Aucun commentaire:

Enregistrer un commentaire