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.
96956a77a329c7f8622e7c81396655fd?d=identicon&s=25 Justin Williams (Guest)
on 2006-12-29 16: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"=>"address1@aol.com"},
{"address"=>"address2@aol.com"}]}

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