Hi...
 I have 2 tables contacts and contact_addresses
In the model contact.rb I wrote:
 has_many :contact_addresses
and in contact_address.rb
 belongs_to :contact
Each contact may have more than one address in contact_addresses table.
Inorder to edit the address, I did the following:
In the contact_controller:
def edit
 @contact=Contact.find(params[:id])
 @contact_address=ContactAddress.find :all, :conditions => ["contact_id
=?", contact.id]
end
edit.rhtml:
<%for contact_address in @contact_address
        if i==1
      contact_address1 = ContactAddress.new
      contact_address1 = contact_address
      else
        contact_address2 = ContactAddress.new
        contact_address2 = contact_address
        end
        i=i+1
end
%>
<% puts contact_address1.addr_line1 %>  //This is working
<% puts contact_address2.addr_line1 %>   //This is working
<td width="75%"><%= text_field "contact_address1",
"addr_line1", :size
=> 50 %>
<td width="75%"><%= text_field "contact_address2",
contact_address2.addr_line1", "size" => 50 %></td>
But the above code is not working. The value is not printed in the text
box. Can anyone please help me to find solution to this problem.
Regards...
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---