views:

378

answers:

1

I am using rails 3.0.0.beta3 and I am trying to implement form with nested attributes using :accepts_nested_attributes_for.

My form is nested to three levels: Survey >> Question >> Answer.

Survey has_many Questions, and Question has many Answers.

Inside the Survey model, there is :accepts_nested_attributes_for :questions

and inside the question mode, there is :accepts_nested_attributes_for :answers

Everything is working fine except when I add a new answer to an existing question, it doesn't get created. However, if I make changes to the corresponding question while creating the answer, I can successfully create the answer.

This example is exactly similar to a railscast: http://railscasts.com/episodes/197-nested-model-form-part-2

but doesn't work in rails3 (at least in my case).

Please let me know if there is any issue with nested attributes in Rails 3.

Thanks in advance.

A: 

Take a look at comment 93 on that railscast (by Casper Fabricus). He says you have to put "[]" around "new_object" in the "link_to_add_fields" method in helper.

Maybe that's what you're hitting?

thermans