0
在我的Rails 5應用程序中,我遵循Ryan Bates的#196關於3個父對象上的嵌套窗體。當使用他的應用助手(如下)時,它返回3個新的字段集。爲什麼/在哪裏循環關聯?我怎樣才能讓它只渲染一次表單?Rails 5 - 幫助程序呈現多次
謝謝!
def link_to_add_fields(name, f, association)
new_object = f.object.send(association).klass.new
id = new_object.object_id
fields = f.simple_fields_for(association, new_object, child_index: id) do |f|
render(association.to_s.singularize + "_fields", f: f)
end
link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
end