# Select\_tag form \[extreme noob help\]

**URL:** <https://www.ruby-forum.com/t/select-tag-form-extreme-noob-help/145463>\
**Category:** Rails\
**Created:** [August 10, 2008, 5:07am UTC](https://www.ruby-forum.com/t/select-tag-form-extreme-noob-help/145463 "2008-08-10T05:07:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![athel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/839c29/32.png) [@athel](https://www.ruby-forum.com/u/athel)\
**Post date:** [August 10, 2008, 5:07am UTC](https://www.ruby-forum.com/t/select-tag-form-extreme-noob-help/145463/1 "2008-08-10T05:07:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![athel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/839c29/32.png) [@athel](https://www.ruby-forum.com/u/athel)\
**Post date:** [August 10, 2008, 8:22am UTC](https://www.ruby-forum.com/t/select-tag-form-extreme-noob-help/145463/2 "2008-08-10T08:22:20Z")

</div>

On Aug 9, 8:07 pm, Athel [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![athel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/839c29/32.png) [@athel](https://www.ruby-forum.com/u/athel)\
**Post date:** [August 10, 2008, 8:24am UTC](https://www.ruby-forum.com/t/select-tag-form-extreme-noob-help/145463/3 "2008-08-10T08:24:40Z")

</div>

On Aug 9, 11:21 pm, Matt H [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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”, …]

---

<div class="post-metadata">

**Author:** ![athel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/839c29/32.png) [@athel](https://www.ruby-forum.com/u/athel)\
**Post date:** [August 10, 2008, 9:40am UTC](https://www.ruby-forum.com/t/select-tag-form-extreme-noob-help/145463/4 "2008-08-10T09:40:38Z")

</div>

omg, bless you…
