I'm trying to create a checkbox survey on a page in my app but I want to store each answer to each question in a different model/table.
I don't want to use one of the survey gems because none seem to meet my needs.
So, say, I have a question with the answers underneath which I want to save to the colors model:
<p>Survey Question 3</p>
<label for="shapes[]">What is your favourite color?</label>
<br><%= check_box_tag 'colors[]', 'blue' %> Blue
<br><%= check_box_tag 'colors[]', 'red' %> Red
<br><%= check_box_tag 'colors[]', 'green' %> Green
<br><%= check_box_tag 'colors[]', 'yellow' %> Yellow
...
(I don't even know if an array is what I need!) User selects their answer and the answer is saved to that table. And then for the next question it is saved to a different table etc - in the one survey.
How would I do this? I know I can't provide much code so i'm hoping someone understands what I am trying to do. Just some guidance in the right direction is all i'm looking for. Thanks.
Aucun commentaire:
Enregistrer un commentaire