Populating drop down

hi all,
i need help in populating a combo box with table data.
any sample code out there?


most probably you want to use the collection_select helper in your

first, in your controller action, grab the contents of the table you
want to use to populate the combo


class TestController < ApplicationController

def index
@categories = Category.find(:all)


Then in your view, add the following code to insert a form and combo

<% form_for :articles do |f| %>
<%= f.collection_select(:category_id, @categories, :id, :name) %>
<% end %>

This is assuming you have a table in your db named categories which
has an ‘id’ and ‘name’ column, and you want to save the id into the
column ‘category_id’ in the table ‘articles’

Just substitute out these names if yours are different.

I find this is the best place to read up on the myriad helpers and
methods available in rails: http://www.gotapi.com/rubyrails

On Dec 30, 5:28 pm, Zablon O. [email protected]

thanks. i think i luck elaborate ref material.