views:

32

answers:

0

I have the following helper:

def new_child_fields_template(form_builder, association, options = {})
  options[:object] ||= form_builder.object.class.reflect_on_association(association).klass.new
  options[:partial] ||= association.to_s.singularize
  options[:form_builder_local] ||= :f

  content_tag(:div, :id => "#{association}_fields_template", :style => "display: none") do
    form_builder.fields_for(association, options[:object], :child_index => "new_#{association}") do |f|
      render(:partial => options[:partial], :locals => {options[:form_builder_local] => f})
    end
  end
end

It's being called from my view like this:

<%= new_child_fields_template(f, :elements)%>

Oddly enough, it only outputs the outer: content_tag(:div, :id => "#{association}_fields_template", :style => "display: none") tag, but nothing inside that block gets output.