I have a rails helper method that is called by:
<%= link_to_add_fields "Add Product", f, :products %>
in application_helper.rb:
def link_to_add_fields(name, f, association)
new_object = f.object.send(association).klass.new
id = new_object.object_id
fields = f.fields_for(association, new_object, child_index: id) do |builder|
render(association.to_s.singularize + "_fields", f: builder)
end
"<div>BLAHBLAHBLAH</div>" +
link_to(name, '#', class: 'add_fields', data: {id: id, fields: fields.gsub('\n', '')})+ ""
end
But this returns everything visible as text on the web page. How do I return both the div and the link_to, so they are both rendered correctly?