Select_tag form [extreme noob help]

Ok, so I’m trying to develop a drop down box with only 3 options. I
can either successfully get the drop down box created, but not able to
save it to the database -OR- it completely crashes.

I have 3 options for “business units”. the field name is bus_unit in
mysql.

I currently have:

<%= f.select :bus_unit, options = {“Option 1”,“Option 2”,“Option 3”}
%>

I’ve tried every viable option on the api as well as googling and have
not been successful.

Any help is greatly appreciated.

On Aug 9, 8:07 pm, Athel [email protected] wrote:

Ok, so I’m trying to develop a drop down box with only 3 options. I
can either successfully get the drop down box created, but not able to
save it to the database -OR- it completely crashes.

In your controller:

@business_units = BusUnit.find(:all)

In your view:

<%= f.collection_select :bus_unit, @business_units, :id, :name %>

Where the symbol :name maps to a field/method in BusUnit to be used as
the display name.

On Aug 9, 11:21 pm, Matt H [email protected] wrote:

In your view:

<%= f.collection_select :bus_unit, @business_units, :id, :name %>

Where the symbol :name maps to a field/method in BusUnit to be used as
the display name.

Also, if you’re not using a model to store the options, you can just
change the line in controller to:

@business_units = [“Option 1”, …]

omg, bless you…