# Updating a record with select

**URL:** <https://www.ruby-forum.com/t/updating-a-record-with-select/128413>\
**Category:** Rails\
**Created:** [February 7, 2008, 3:05pm UTC](https://www.ruby-forum.com/t/updating-a-record-with-select/128413 "2008-02-07T15:05:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [February 7, 2008, 3:05pm UTC](https://www.ruby-forum.com/t/updating-a-record-with-select/128413/1 "2008-02-07T15:05:55Z")

</div>

Hello,

I have displayed a list of people and now i want to assign them a  
relation for example … friend, brother,stranger,etc. the list of  
relations is stored with me.  
How can I use the select option(probably have to use onchange) so that  
the moment i select the relation the record of the person is updated.  
The name of the table from where i have to pick the relations is  
“relations”

Person model  
belongs\_to :person

relation model  
has\_many :people

show.rhtml in view  
\<removed\_email\_address@domain.invalid do |person|%\>

\<%=$i%\> \<%= link\_to (image\_tag(person.public\_filename(:thumb)), person.public\_filename) rescue nil%\> \<%=link\_to person.title,:controller=\>"person",:action=\>"edit",:id=\>person.id%\> \<%=link\_to person.first\_name,:controller=\>"person",:action=\>"edit",:id=\>person.id%\> \<%=link\_to person.last\_name,:controller=\>"person",:action=\>"edit",:id=\>person.id%\> \<%=link\_to person.email1,:controller=\>"person",:action=\>"edit",:id=\>person.id%\> select statement goes here.......what should be written here \<%$i = $i+1%\>

Thank you.
