# help with FormOptionsHelper

**URL:** <https://discuss.rubyonrails.org/t/help-with-formoptionshelper/25517>\
**Category:** rubyonrails-talk\
**Created:** [February 27, 2008, 1:24pm UTC](https://discuss.rubyonrails.org/t/help-with-formoptionshelper/25517 "2008-02-27T13:24:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dino\_d](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@dino\_d](https://discuss.rubyonrails.org/u/dino_d)\
**Post date:** [February 27, 2008, 1:24pm UTC](https://discuss.rubyonrails.org/t/help-with-formoptionshelper/25517/1 "2008-02-27T13:24:56Z")

</div>

Hi -

I'm trying to understand the help for this:

> **[ActionView::Helpers::FormOptionsHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000940)**
>
> Provides a number of methods for turning different kinds of containers into a set of option tags.

it says:

select(object, method, choices, options = {}, html\_options = {})

questions-

1) what is 'object' ? Is this an ActiveRecord object? 2) what is method? 3) do i assume that my form object created from form\_for calls select directly? 4) what is the form of object- is it "user", @user, user, or :user ? Please explain why, this is terribly confusing for a newbie.

So, if I have a view:

\<% content\_for(:page) do %\> \<h1\>New user\</h1\> \<% form\_for :user, @user, :url =\> { :action =\> "create" } do |form| %\> #NOTE I'M TRYING TO USE FORM\_FOR \<%= render :partial =\> 'form', :locals =\> { :form =\> form, :genders =\> @genders, :user=\>@user} %\> #SEND THE FORM INSTANCE DOWN TO PARTIAL \<%= submit\_tag "Create" %\> \<%end%\> \<%end%\>

Notice I'm attempting to send the current user to the partial, I'm not sure if I'm doing this right. Also, my controller created a User instance (@user) which I'm sending to the partial.

and the partial:

\<p\> \<label\> Last Name\<br/\> \<%= form.text\_field :lastname %\> \</label\> \</p\> ...

\<p\> \<label\> Gender\<br/\> \<%= form.select('user', "gender", {"Male" =\> 1, "Female" =\>2 })%\> #THIS DOESN'T WORK \</label\> \</p\>

Note, there is no gender table, just 2 choices. User has a gender field which is an integer.

So all I'm trying to do is let the client choose a gender from a select box. Please tell me what I'm doing wrong and if possible, answer my questions above.

Thanks, Dino

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [February 27, 2008, 1:42pm UTC](https://discuss.rubyonrails.org/t/help-with-formoptionshelper/25517/2 "2008-02-27T13:42:15Z")

</div>

> Hi -
> 
> I'm trying to understand the help for this:
> 
> [ActionView::Helpers::FormOptionsHelper](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000940)
> 
> it says:
> 
> select(object, method, choices, options = {}, html\_options = {})
> 
> questions-
> 
> 1) what is 'object' ? Is this an ActiveRecord object? 2) what is method? 3) do i assume that my form object created from form\_for calls select directly? 4) what is the form of object- is it "user", @user, user, or :user ? Please explain why, this is terribly confusing for a newbie.

1) it's 'user' or :user. rails will look for an instance variable with  
that name 2) it's the name method returning the value to display. This could be  
a db column or a computed property.

form\_for makes things a bit easier: when using form\_for you don't need  
to specify object (since that is setup in the call to form\_for) ie you can do form.select(:gender, ...) (in the same way that you can  
do form.text\_field :lastname)

Fred

---

<div class="post-metadata">

**Author:** ![dino\_d](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@dino\_d](https://discuss.rubyonrails.org/u/dino_d)\
**Post date:** [February 27, 2008, 2:42pm UTC](https://discuss.rubyonrails.org/t/help-with-formoptionshelper/25517/3 "2008-02-27T14:42:54Z")

</div>

> form\_for makes things a bit easier: when using form\_for you don't need to specify object (since that is setup in the call to form\_for) \<=============== ie you can do form.select(:gender, ...) (in the same way that you can do form.text\_field :lastname)
> 
> Fred

OOOH!!!! Now i get it. Thanks for the great response. The docs are just not newbie friendly.

Dino
