# Select\_tag taking input from database

**URL:** <https://www.ruby-forum.com/t/select-tag-taking-input-from-database/189100>\
**Category:** Rails\
**Created:** [May 24, 2010, 3:54pm UTC](https://www.ruby-forum.com/t/select-tag-taking-input-from-database/189100 "2010-05-24T15:54:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![slippy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/839c29/32.png) [@slippy](https://www.ruby-forum.com/u/slippy)\
**Post date:** [May 24, 2010, 3:54pm UTC](https://www.ruby-forum.com/t/select-tag-taking-input-from-database/189100/1 "2010-05-24T15:54:09Z")

</div>

hey, its my first day developing with ruby and i am having some  
trouble getting data from a find and then putting it in a select drop  
down.

here is my code,

IN MY CONTROLLER  
@foundCode = Code.find(:all)

IN MY VIEW  
\<%= f.select\_tag ‘code’, options\_for\_select(@foundCode) %\>

THE OBJECT

- !ruby/object:Code  
attributes:  
name: Locations  
created\_at: 2010-05-22 09:57:42  
updated\_at: 2010-05-22 10:17:10  
id: “2”  
value: NY  
attributes\_cache: {}

- !ruby/object:Code  
attributes:  
name: Locations  
created\_at: 2010-05-22 10:16:58  
updated\_at: 2010-05-22 10:16:58  
id: “6”  
value: London  
attributes\_cache: {}

Thanks

Alex

---

<div class="post-metadata">

**Author:** ![slippy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/839c29/32.png) [@slippy](https://www.ruby-forum.com/u/slippy)\
**Post date:** [May 24, 2010, 4:09pm UTC](https://www.ruby-forum.com/t/select-tag-taking-input-from-database/189100/2 "2010-05-24T16:09:22Z")

</div>

Solved it.

VIEW  
\<%= select (“proCodes”, “id”, @productCode.map {|u| [u.value,u.id]})  
%\>
