且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 simple_form 和 rails 4 创建多个嵌套表单

更新时间:2023-11-24 10:32:16

你弄错了:= q.simple_fields_for :answers, q.questions.build do |a|您在构建器对象 q 而不是模型对象上调用 questions 方法.可能你想要这个:

You got it wrong here: = q.simple_fields_for :answers, q.questions.build do |a| You are calling questions method on builder object q instead of a model object. Probably You want this:

= q.simple_fields_for :answers, q.object.questions.build