I have a nested form for survey responses, but the form data is not
being posted to the table; I get no errors, just null values for the
data from params (‘question_id’, ‘answer_id’ and ‘note)’.
Please help!!! And thanks in advance !!
Model:
class CreateResponses < ActiveRecord::Migration
def self.up
create_table :responses do |t|
t.integer :request_id
t.integer :question_id
t.integer :answer_id
t.text :note
t.timestamps
end
end
Controller:
def survey_response
@request = Request.find(params[:id])
@survey = Survey.find(:first, :conditions => id =
@request.survey_id)
@question = Question.find(:all, :conditions => survey_id =
@survey.id)
@resultSet = Array.new
@question.each do |question|
answers = Answer.find(:all, :conditions => [“question_id = ?”,
question.id])
questionAnswerPair = [question, answers]
@resultSet << questionAnswerPair
questionAnswerPair=[]
answers=[]
end
if request.post?
@response = Response.new(:request_id => @request.id,
:question_id => (params[:question_id]),
:answer_id => (params[:answer_id]),
:survey_id => @survey.id,
:note => (params[:note])
)
end
end
survey_response View:
Additional Comments:
<%= f.text_area :note, :size => "60x5" %>
<%= f.submit "Submit" %>
<% end %>