def link_to_add_nested_fields(name, f, association, klasss, type)
new_object = f.object.send(association).klass.new
id = new_object.object_id
field = f.fields_for(association, new_object, child_index: id) do |builder|
render(association.to_s.singularize + "_#{type}", f: builder)
end
link_to(name, '#', class: klasss, data: {id: id, type: field.gsub("\n", "")})
end
我正在尝试自定义一个我从这里获得的帮助代码http://railscasts.com/episodes/196-nested-model-form-revised,但我遇到了类型参数的问题。使用此助手的示例;
<%= link_to_add_nested_fields "Add custom field", f, :fields, "add_fields","fields" %>
问题肯定出在类型参数上,有谁知道我该如何解决这个问题?谢谢