I have a problem I can''t seem to find an answer to. I have the
following relations
(contact) 1 == *(Phone) *== (Phone Type).
(contact) 1 == 1 (Address)
I will be constructing an AJAX interface that allows user to add
multiple rows to the contact. As such, I want to make it possible to
get them from the request. I have the following for contact and
address, which works
@company_contact = CompanyContact.new(params[:company_contact])
@address = Address.new(params[:address])
@company = Company.find(params[:company])
@company_contact.company = @company
@company_contact = @address
#TODO phones.
How do I get the phones to work? I''ve tried the following.
@phones = Phone.new(params[:phones])
but it doesn''t return anything, just nill. My embedded form looks
like this.
<h2>Phones</h2>
<table>
<% for phone in @phones do%>
<tr><td>Number:</td><td> <%=
text_field("phone" , "number") %></td>
<td><%= get_phone_types %></td></tr>
<% end %>
<table>
and my call to the template looks like this
<%= render (:partial => "shared/formphone", :object =>
@phones @company_contact.phone()) %>
When I look at the HTML it just generates the following
<tr><td>Number:</td><td> <input
id="phone_number" name="phone[number]"
size="30" type="text" /></td> <td><select
id="phone_phone_type_id"
name="phone[phone_type_id]"><option
value="3">business</option>
<option value="4">fax</option>
<option value="2">home</option>
<option
value="1">mobile</option></select></td></tr>
<tr><td>Number:</td><td> <input
id="phone_number" name="phone[number]"
size="30" type="text" /></td> <td><select
id="phone_phone_type_id"
name="phone[phone_type_id]"><option
value="3">business</option>
<option value="4">fax</option>
<option value="2">home</option>
<option
value="1">mobile</option></select></td></tr>
<tr><td>Number:</td><td> <input
id="phone_number" name="phone[number]"
size="30" type="text" /></td> <td><select
id="phone_phone_type_id"
name="phone[phone_type_id]"><option
value="3">business</option>
<option value="4">fax</option>
<option value="2">home</option>
<option
value="1">mobile</option></select></td></tr>
<tr><td>Number:</td><td> <input
id="phone_number" name="phone[number]"
size="30" type="text" /></td> <td><select
id="phone_phone_type_id"
name="phone[phone_type_id]"><option
value="3">business</option>
<option value="4">fax</option>
<option value="2">home</option>
<option
value="1">mobile</option></select></td></tr>
As you can see, all the input fields are the same. Is there a way I
can make them unique, as well as easily get them from the request?
Any help would be greatly appreciated!
thanks,
Todd
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---