ruby on rails- nested attributes for 'has_one' relationship
- by Kum
Hello,
I need some help concerning nested attributes in models with 'has_one' relationship.
Model Survey has 1 question
Model Question has 1 answer
How do i build the 'answer' in the code below
def new
@survey = Survey.new
@survey.build_question # build one question
@survey.question.answer.build #this part is not working
end
Please can anybody tell me how to build the answer as the code "@survey.question.answer.build" is not correct.
Many many thanks for your help