It doesn't work as I expected.
I changed the controller and view but it doesn't work
in report_controller.rb
def new
...
QuestionSingle.each do |qs|
report.answer_singles.build ...
end
so answer_single generated as many as questions.
So when I call answer_singles in the fields for it calls every
answer_singles generated.
<div class="question">
<% QuestionSingle.all.each_with_index do |question, index| %>
<p><%= index+1 %>. <%= question.content %></p>
<%= f.fields_for :answer_singles do |answer| %>
<%= answer.text_area :content %>
<%= answer.hidden_field :question_single_id, {:value => index}
%>
<% end %>
<% end %>
</div>
I have designed models not like report -> question -> answer
report -> answer (due to the predefined questions by scaffolding)
For all report same questions will be fed and answers have report_id,
question_id. My question is how I can use answer same as the
question_id.
Simple fields for shows all answer fields having same report_id.
Let me know if there's better design for predefined questions.
Thanks,
June
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.