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

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and 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 %>

      <%= 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.


This topic is locked and can not be replied to.