Hi All,
I have 4 models - Users, Lessons, Questions & Answers. Each user can create a lesson with some questions and then ask other users to answer those questions and submit the form. I ran into a problem creating a view to display a lesson with a list of questions and a blank answer field underneath each question. I have a working code (shown here) that loops through questions and shows a text field for each question and answer. I am trying to change it so that the questions are shown as headers and answers are shown as editable fields. I hope this makes sense. I am a noob with RoR. I couldn't find an answer online. Thank you so much.
--View
<% form_for @lesson do |f| %>
<%= f.error_messages %>
<% f.fields_for :questions do |builder| %>
<%= render "question_fields", :f => builder %>
<% end %>
<p><%= f.submit "Submit Answers"%>
<% end %>
--partial _question_fields.html.erb
<%= f.text_area :prompt, :rows => 1 %> <br />
<% f.fields_for :answers do |builder| %>
<%= render "answer_fields", :ff => builder %>
<% end %><br />
--partial _answer_fields.html.erb
<%= ff.text_area :data, :rows => 3 %>