Forum: Ruby on Rails Partials And the :index parameter

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Justin W. (Guest)
on 2006-12-29 17:32
(Received via mailing list)
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"}]}

2) 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.
http://carpeaqua.com/
This topic is locked and can not be replied to.