I have a Survey-Response application, where surveys can be created with an arbitrary number of questions, and users can respond to an arbitrary number of surveys.
A Survey has_many Questions and has_many Responses. Both a Question and a Response has_many Answers. That way, everybody has a relationship to everyone else. In the Response#new for each Response.survey.questions I do a @response.answers.build and set the questions_id attribute. That looks like this: 1: survey = Survey.find(params[:survey_id]) 2: @response = survey.responses.build 3: @response.survey.questions.each do |question| 4: @response.answers.build(:question_id => question.id) 5: end All I want to do in the form template is get the Answer's Question's text to display as a label. That looks like this: 6: <% f.fields_for :answers do |fields| %> 7: <p>Q: <%= Question.find(fields[:question_id]).ask %></p> 8: <p>A: <%= fields.text_field :content %><br /></p> 9: <% end %> Obviously Line 7 is junk, but that's basically what I want to do. How do I get those prepopulated attribute values? I haven't been able to find anything on this so it's either obviously staring me in the face or an odd question. I found this similar question, but it hasn't received a reply. http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/115dbb1ba9215b0f/33779ed24e48c26c?lnk=gst&q=attributes+form#33779ed24e48c26c Thanks in advance. Dee -- 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.

