# Help with FormOptionsHelper

**URL:** <https://www.ruby-forum.com/t/help-with-formoptionshelper/130338>\
**Category:** Rails\
**Created:** [February 27, 2008, 2:25pm UTC](https://www.ruby-forum.com/t/help-with-formoptionshelper/130338 "2008-02-27T14:25:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [February 27, 2008, 2:25pm UTC](https://www.ruby-forum.com/t/help-with-formoptionshelper/130338/1 "2008-02-27T14:25:26Z")

</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 %\>

# New user
\<% 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:

Last Name  
\<%= form.text\_field :lastname %\>

...

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

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:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [February 27, 2008, 2:43pm UTC](https://www.ruby-forum.com/t/help-with-formoptionshelper/130338/2 "2008-02-27T14:43:11Z")

</div>

On 27 Feb 2008, at 13:24, dino d. wrote:

> 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://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [February 27, 2008, 3:43pm UTC](https://www.ruby-forum.com/t/help-with-formoptionshelper/130338/3 "2008-02-27T15:43:37Z")

</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
