ryanb/nested_form — pull request #115 by jdkealy (2011-11-05 12:48:58+00:00)
Title: has_many through support for object building

Hi I had trouble using this gem for has_many => :through scenarios.

As would be the case below, if I used link_to_add :memberships below, the gem would build the membership but leave out its associated organisation. So I copied one of your methods and threw in another parameter to have it build the associated object. Below is a use case, you can see link_to_add_hmt in the pull request. Thanks!

= f.fields_for :memberships do |mem|
= mem.fields_for :organisation do |org|
.row
.span5.org_name
= org.input :name, :label => "Name of the Organization"
.span5
= mem.input :title, :label => "Title in the Organization"
.row
.span5
= mem.input :starting_year, :label => "Starting Year"
.span5
= mem.input :ending_year, :label => "Ending Year"
.row
.span10
= org.text_area :description, :label => "Description of Organisation"
= mem.link_to_remove "Remove this oranisation"
= f.link_to_add_hmt "Add an organisation", :organisation, :memberships