Created
October 21, 2010 22:59
-
-
Save salbito/639543 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Answers new method | |
def new | |
@survey = Survey.find(params[:survey_id]) | |
@questions = @survey.questions.all | |
@answers = @questions.map{|q| q.answers.build} | |
respond_to do |format| | |
format.html # new.html.erb | |
format.xml { render :xml => @answer } | |
end | |
end | |
Answers View | |
= for answer in @answers$ | |
%p= answer.answer_string$ | |
%p= answer.question_id$ | |
Html Output | |
<div id='body_con'> | |
<h1>New answer</h1> | |
<p></p> | |
<p>1</p> | |
<p></p> | |
<p>3</p> | |
<p></p> | |
<p>5</p> | |
<p></p> | |
<p>7</p> | |
<p></p> | |
<p>9</p> | |
[#<Answer id: nil, answer_string: nil, created_at: nil, updated_at: nil, question_id: 1, user_id: nil>, #<Answer id: nil, answer_string: nil, created_at: nil, updated_at: nil, question_id: 3, user_id: nil>, #<Answer id: nil, answer_string: nil, created_at: nil, updated_at: nil, question_id: 5, user_id: nil>, #<Answer id: nil, answer_string: nil, created_at: nil, updated_at: nil, question_id: 7, user_id: nil>, #<Answer id: nil, answer_string: nil, created_at: nil, updated_at: nil, question_id: 9, user_id: nil>] | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment