Partials And the :index parameter


#1

Greetings,

I have a Client model with a has_many relationship to an Email model.
On my user form I am allowing the user to associate multiple email
addresses to a client and assign one of them as the primary address.
I have created a partial called _email that I am rendering as a
collection from an @emails array.

My issues:

  1. I cannot get the :index parameter to work with the text_field in the
    partial when rendering a collection of the _email partial. Relevant
    code.

<%= text_field :email, :address, :index => :email, :size => 25 -%>

The parameters list shows up as
“email”=>[{“address”=>“removed_email_address@domain.invalid”},
{“address”=>“removed_email_address@domain.invalid”}]}

  1. When a new client is first created, there are no email addresses
    associated with it, but i would like to render my partial with index 1
    and then subsequent partials added afterwards via link_to_remote will
    continue that index numbering (2,3,4,etc). This may not work because
    of #1, but I thought I’d throw it out there all the same.

Help is greatly appreciated.

Thanks!

Justin W.