I have the following code in partial format _form.html.haml, which is used for new actions and editing actions. (fyi I am using the Ryan Bates nested_form plugin )
.fields
- f.fields_for :transportations do |builder|
= builder.collection_select :person_id, @people, :id, :name, {:multiple => true}
= builder.link_to_remove 'effacer'
= f.link_to_add "ajouter", :transportations
works fine for a new action ... for an editing action, as the document explains, I have to add: id of already existing associations, so I have to add something like
= builder.hidden_field :id, ?the value? if ?.new_record?
How can I get the value?
Here is the accepts_nested_attributes_for document for reference (source: http://github.com/rails/rails/blob/master/activerecord/lib/active_record/nested_attributes.rb#L332 )
Thank you for your help.