# Beginner: help using \<select\> drop down list

**URL:** <https://www.ruby-forum.com/t/beginner-help-using-select-drop-down-list/51744>\
**Category:** Rails\
**Created:** [January 6, 2006, 4:11pm UTC](https://www.ruby-forum.com/t/beginner-help-using-select-drop-down-list/51744 "2006-01-06T16:11:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![homestarrunner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/71e660/32.png) [@homestarrunner](https://www.ruby-forum.com/u/homestarrunner)\
**Post date:** [January 6, 2006, 4:11pm UTC](https://www.ruby-forum.com/t/beginner-help-using-select-drop-down-list/51744/1 "2006-01-06T16:11:48Z")

</div>

Hi, first time posting here. I’m in the process of learning ruby and the  
rails framework and i’ve come to a road block. I started off by using  
the Onlamp tutorial online and got a test database and all of the  
generated scaffold pages. I am currently working on a drop down box  
using the select tag. I figured out how to get values from a ‘name’  
column in my Test table, i’m using mysql for database access.

The problem i’m stuck at now is that I want to be able to select a name  
from the list and click a button and have it forward to the ‘show.rhtml’  
page for the selected name. I’m trying to reformat the ‘list.rhtml’  
page that was created by the scaffold generator, so that there is only  
this drop down box, instead of having all the rows in the table show up  
with all the columns and data.

If anyone can help me that would be great. i’ve googled all day and  
found no examples to help me with this.

thanks

---

<div class="post-metadata">

**Author:** ![homestarrunner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/71e660/32.png) [@homestarrunner](https://www.ruby-forum.com/u/homestarrunner)\
**Post date:** [January 6, 2006, 6:21pm UTC](https://www.ruby-forum.com/t/beginner-help-using-select-drop-down-list/51744/2 "2006-01-06T18:21:30Z")

</div>

Hi, Mike,

please try this (fitting it to your needs):

In your controllers list method load all items (in my example books)  
into an instance variable:

@books = Book.find(:all)

In your list-view display these books in a select box with:

\<%= start\_form\_tag :action =\> ‘show\_book’ %\>  
\<%= collection\_select(:book, :id, @books, :id, :title) %\>  
\<%= submit\_tag ‘Show’ %\>  
\<%= end\_form\_tag %\>

after submitting with the show button you can catch a parameter  
params[:book][:id] and use this to find the book that you would like to  
display.

def show\_book  
redirect\_to(:action =\> “show”, :id =\> params[:book][:id])  
end

Regards  
Jan

---

<div class="post-metadata">

**Author:** ![homestarrunner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/71e660/32.png) [@homestarrunner](https://www.ruby-forum.com/u/homestarrunner)\
**Post date:** [January 6, 2006, 7:15pm UTC](https://www.ruby-forum.com/t/beginner-help-using-select-drop-down-list/51744/3 "2006-01-06T19:15:22Z")

</div>

Thanks for the help, I follow what you are saying. I’m gonna give it a  
try and see how it goes.

Thanks again
