Some clients will have 30 questions and answers, some will have 20 and some will have 10. Those that have 10 or 20 can increase to the next level. In the controller i need to fill in for the answers that are missing. I had hoped to create one array in the controller with the question and answer matched and then send one array to the view.
@questions = Question.order("qtype, position")
@answers = Answer.where(user_id = current_user.id)
@questions.each do |q|
@qa[q,0] = q.question
@qa[q,1] = @answers.find_by_question_id(q.id)
if @qa[q,1].empty?
@qa[q,1] = 0
end
end
I am getting "undefined method `question'." Don't know what i am doing wrong.
Thanks.