Forum: Ruby on Rails accepts_nested_attributes_for and add/remove nested model forms with JS

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Branko V. (Guest)
on 2009-05-21 01:45
(Received via mailing list)
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 %>

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

    <table id="recipe_ingredients">
      <tr>
        <th>ingredient</th>
        <th>in units</th>
        <th>quantity</th>
        <th>delete?</th>
      </tr>
      <% f.fields_for :recipe_ingredients do |ri_f| %>
        <%= render :partial => 'recipe_ingredient', :locals => { :f =>
ri_f } %>
      <% end %>
    </table>
    <p>
      <%# Add new item link here... %>
    </p>

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

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.

1: http://github.com/alloy/complex-form-examples/tree/master

--
Branko
This topic is locked and can not be replied to.