views:

50

answers:

1

I can't figure-out how to get at the underlying object in a form_for or field_for block.

What I'd like to do is something like:

<% f.fields_for :children do |child_form| %>
  <%= render :partial => "#{child_form.underlying_object.class.name.downcase}" %>
<% end %>

and :children is a polymorphic has_many association.

Suggestions?

+1  A: 

Isn't it just

<% f.fields_for :children do |child_form| %>
<%= render :partial => "#{child_form.object.name.downcase}" %>
<% end %>
Damian
Oh so close! :-)child_form.object.class.name is the magic.Thanks!
Mike