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
Mike Y. wrote:
>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
>
>