# Form.select question

**URL:** <https://www.ruby-forum.com/t/form-select-question/118653>\
**Category:** Rails\
**Created:** [October 29, 2007, 8:48pm UTC](https://www.ruby-forum.com/t/form-select-question/118653 "2007-10-29T20:48:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_Hackenyos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7c8e57/32.png) [@Dave\_Hackenyos](https://www.ruby-forum.com/u/Dave_Hackenyos)\
**Post date:** [October 29, 2007, 8:48pm UTC](https://www.ruby-forum.com/t/form-select-question/118653/1 "2007-10-29T20:48:51Z")

</div>

Hello,  
I am new to rails and have a question about form.select. I  
understand the examples that have a select drop down selections which  
map to a column in the model’s database row. What I want to do is  
provide a drop down list for selections which do not map to a single  
column in a row but which maps to any one of the columns in the table.

The list would be defined in the model class, named say Book:  
SORT\_TYPES = [[“id”, “id”],  
[“price”, “price”]  
[“color”, “color”]]

The form would look something like:  
\<% form\_for :book, :url =\> { :action =\> :sort } do |form| %\>  
\<%= form.select :sort\_type,  
Book::SORT\_TYPES,  
:prompt =\> “sort reviews  
by”  
%\>  
\<%= submit\_tag “Sort”, :class =\> “submit” %\>  
\<% end %\>

When the form is submitted, the sort method of the Book\_controller is  
called and I want to trap the value the user chose from the drop down  
list of options, each of which is a column in the books table. I know  
the sort method is called but I can’t seem to get a value from the  
selection.

So the question is: How do I trap a value from a form.select which is  
not mapped to a single column from a model’s table but to one of the  
table’s columns? How about the select return any arbitrary value (one  
not associated with a database table)?

Any help would be greatly appreciated.

Thanks for your time,  
Dave Hackenyos  
removed\_email\_address@domain.invalid

Videx Inc. 1105 N. E. Circle Blvd. Corvallis OR 97330 (541) 758-0521  
CONFIDENTIAL COMMUNICATION: The email message and any attachments are  
intended only for the addressee. They may be privileged, confidential,  
and protected from disclosure. If you are not the intended recipient,  
any dissemination, distribution, or copying is expressly prohibited. If  
you received this email message in error, please notify the sender  
immediately by replying to this e-mail message or by telephone
