Joined March 2015
·

Mark Coleman

Fort Collins, Colorado
·
·
·

Posted to Nested form and Rails 4 over 1 year ago

If you can't get this to work with another doubly or more nested has many relationships, I'd check the server log. If all works but the save, most likely you have strong parameter issue. For the survey - question - answer two-level scenario, I added method to build answers collection to Question model class, but instead of the questions controller, I included answers_attributes in my survey_params private method in the survey controller, not the questions controller. I nested in the questions_attributes, like so:

params.require(:survey).permit(:title, questions_attributes: [ :id, :text, :_destroy,   answers_attributes: [ :id, :content, :_destroy ]])
Achievements
1 Karma
0 Total ProTip Views