# :select with select helper

**URL:** <https://www.ruby-forum.com/t/select-with-select-helper/113484>\
**Category:** Rails\
**Created:** [August 31, 2007, 3:48pm UTC](https://www.ruby-forum.com/t/select-with-select-helper/113484 "2007-08-31T15:48:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [August 31, 2007, 3:48pm UTC](https://www.ruby-forum.com/t/select-with-select-helper/113484/1 "2007-08-31T15:48:49Z")

</div>

Here is an interesting behavior that I have noticed is rather common  
with R0R. I have two select helpers being used in a form. Both are  
supposed to display a list of stuff, but if either should already have  
an item in that list accosiated with a value in the table it should  
display that value in the list. However, one does and one does not. Here  
is the code:

\<%= select ‘bar’, ‘account\_id’, Account.find\_by\_sql( “SELECT  
accounts.accountcode ||’ '|| accounts.name AS accountcode, id from  
accounts  
ORDER BY accounts.accountcode ASC” ).collect{ |a| [a.accountcode,  
a.id] }, :selected =\> @bar.account\_id %\>

This one works perfectly well and display the correct selected item.

\<%= select ‘enpseudo’, ‘pseudocity’, Enpseudo.find( :all ).collect{ |a|  
[a.pseudocity, a.id] }, :selected =\> @enpseudo.pseudocity %\>

This one, however, does not display the correct item in the list if one  
is aleardy present in the table. I have checked the output and the  
output it gives does indeed match an item in the list but it is  
odviously not making the accassiation. Any suggestions of what I am  
doing wrong? Thanks

-Shandy

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [August 31, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/select-with-select-helper/113484/2 "2007-08-31T16:40:22Z")

</div>

I realized what I was doing. I was trying to match what was betwen the

 tags and not what was in the value of the tag. And that value was an idea and not a string of whatever characters.
