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
I'm trying to customise a piece a helper code i got from here http://railscasts.com/episodes/196-nested-model-form-revised, but i'm having problems with the type parameter. An example of this helper being used;
<%= link_to_add_nested_fields "Add custom field", f, :fields, "add_fields","fields" %>
The problem is definitely with the type parameter, does anyone know how i can solve this? Thanks