Accepts_nested_attributes_for and add/remove nested model forms with JS


I’ve looked at the complex_form example app on GitHub, but I’m not
sure I understand how it works.

For now I’ve managed to display the partial using the render command,
and stopped at the “add new item” link… Here’s the current code:

<%= f.error_messages %>

  <%= f.label :name %><br />
  <%= f.text_field :name %>

<table id="recipe_ingredients">
    <th>in units</th>
  <% f.fields_for :recipe_ingredients do |ri_f| %>
    <%= render :partial => 'recipe_ingredient', :locals => { :f =>

ri_f } %>
<% end %>

<%# Add new item link here… %>

  <%= f.label :preparation %><br />
  <%= f.text_area :preparation %>

What I’m not clear about in the example app at GitHub[1] is where the
link for creating the new item appears in the template code.
(Unfortunately, I wasn’t able to get the project up on my box, so I
don’t even know how the templates are rendered.)

If someone could explain (even if only in short) what is going on with
the app, or maybe point me to a simpler solution/example, I’d
appreciate it.