Topic: Partials And the :index parameter

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.   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 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"=>"address1@aol.com"}, {"address"=>"address2@aol.com"}]}

2) When the 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.  This may not work because of #1, but I thought I'd throw it out there all the same.

Help is greatly appreciated.

Thanks!

Re: Partials And the :index parameter

is this for the id attribute of the text field?

if so, the code would be:

<%= text_field :email, :address, :id => "email_#{email.id}", :size => 25 %>

you may want to check that


--jake

---------------------------------------------------------------------
Rails Development - Agile rails consulting and development for startups on a budget
Flvorful Blog - Some ramblings
Flvorful's Open Source Projects - Some handy hacks for your rails projects.