# Edit form

**URL:** <https://www.ruby-forum.com/t/edit-form/138797>\
**Category:** Ruby-Forum\
**Created:** [May 27, 2008, 9:17pm UTC](https://www.ruby-forum.com/t/edit-form/138797 "2008-05-27T21:17:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![feras80](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/8e7dd6/32.png) [@feras80](https://www.ruby-forum.com/u/feras80)\
**Post date:** [May 27, 2008, 9:17pm UTC](https://www.ruby-forum.com/t/edit-form/138797/1 "2008-05-27T21:17:58Z")

</div>

Hello  
am a newbie 🙂  
am developing a portal for employees company. there is an edit form that  
allows employees to change their information ( phone number, address,  
etc)  
here is the employees controller

def contact\_information  
current\_user= session[:login]

```
@contact_information= Employee.find_by_sql( "select * from employees

```

where id=’#{current\_user}’")  
end

in the form i have :

\<% for obj in @contact\_information%\>

| \<% form\_tag :action =\> 'save\_contact\_information', :employee=\>@employee do %\> 

```
  </table>

</td>
<td width="48%" rowspan="2" valign="top"> <table width="99%"

```

border=“0” align=“center” cellpadding=“0” cellspacing=“0”  
class=“subtable”\>

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

```
  </table></td>

```

| Work |
| --- |
| Work Location | \<%= text\_field 'employee', 'work\_location' ,:maxlength =\> 50,:size=\>25,:value=\>obj.work\_location %\> |
| Work State | \<%= text\_field 'employee', 'work\_state\_id' ,:maxlength =\> 50,:size=\>25%\> |
| Work Phone | \<%= text\_field 'employee', 'work\_phone' ,:maxlength =\> 50,:size=\>25,:value=\>obj.work\_phone %\> |
| Mobile Phone | \<%= text\_field 'employee', 'mobile\_phone' ,:maxlength =\> 50,:size=\>25,:value=\>obj.mobile\_phone %\> |
| Work Fax | \<%= text\_field 'employee', 'work\_fax' ,:maxlength =\> 50,:size=\>25,:value=\>obj.work\_fax %\> |
| Work Email | \<%= text\_field 'employee', 'work\_email' ,:maxlength =\> 50,:size=\>25,:value=\>obj.work\_email %\> |
| Permanent  
Home |
| --- |
| Address 1 | \<%= text\_field ‘employee’, ‘street\_address1’  
,:maxlength =\> 50,:size=\>25,:value=\>obj.street\_address1 %\> |
| Address 2 | \<%= text\_field ‘employee’, ‘street\_address2’ ,:maxlength  
=\> 50,:size=\>25,:value=\>obj.street\_address2 %\> |
| City | \<%= text\_field ‘employee’, ‘city’ ,:maxlength =\>  
50,:size=\>25,:value=\>obj.city%\> |
| State | \<%= select ‘employee’,‘state\_id’, State.find(:all).collect  
{|c| [c.state\_name, c.id]},{:selected=\>obj.state\_id}%\> |
| Postal code | \<%= text\_field ‘employee’, ‘postal\_code’ ,:maxlength =\>  
50,:size=\>25,:value=\>obj.postal\_code%\> |
| Country | \<%= country\_select ‘employee’, ‘country’ %\> |
| Home Phone | \<%= text\_field ‘employee’, ‘home\_phone’ ,:maxlength =\>  
50,:size=\>25,:value=\>obj.home\_phone%\> |
| 

| Current Home |
| --- |
| Address 1 | \<%= text\_field 'employee', 'present\_street\_address1' ,:maxlength =\> 50,:size=\>25,:value=\>obj.present\_street\_address1 %\> |
| Address 2 | \<%= text\_field 'employee', 'present\_street\_address2' ,:maxlength =\> 50,:size=\>25,:value=\>obj.present\_street\_address2 %\> |
| city | \<%= text\_field 'employee', 'present\_city' ,:maxlength =\> 50,:size=\>25,:value=\>obj.present\_city%\> |
| State | \<%= select 'employee','present\_state\_id', State.find(:all).collect {|c| [c.state\_name, c.id]},{:selected=\>obj.present\_state\_id}%\> |
| Postal code | \<%= text\_field 'employee', 'present\_postal\_code' ,:maxlength =\> 50,:size=\>25,:value=\>obj.present\_postal\_code%\> |
| Country | \<%= country\_select 'employee', 'present\_country' %\> |
| Mobile Phone | \<%= text\_field 'employee', 'mobile\_phone' ,:maxlength =\> 50,:size=\>25,:value=\>obj.mobile\_phone%\> |
| Personal Email | \<%= text\_field 'employee', 'personal\_email' ,:maxlength =\> 50,:size=\>25,:value=\>obj.personal\_email%\> |

 |
| \<%= submit\_tag "Save all changes"%\> |

 \<%end%\> \<%end%\>

the problem is when an employee open this page, countrie\_selct always  
shows the first country ( Afghanistan) while it should show something  
else ( India for example), as well as for states.  
any help will be much appreciated  
Thank you  
Feras,

 |
