0
내 레일 5 애플 리케이션에서 3 부모 개체에 중첩 된 양식에 대한 라이언 베이츠 '# 196 따라. 그의 응용 프로그램 도우미 (아래)를 사용하면 3 개의 새로운 필드 세트를 반환합니다. 왜/어디에서 연결 고리가 나옵니까? 양식을 한 번만 렌더링하려면 어떻게해야합니까?레일 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