Help with form_for helper selects

Hey all, I am building a form for my app and I am having some trouble
with creating a select for the form.

In my form_for helper, I am attempting to create a selection drop down
and here is the code for that…

Is this pet Spayed/Neutered?
<%= form.select(Yes,No) :fixed %>

This obviously does not work, but I am not quite sure why it does not
work. Could someone please post a basic example of a select for me, or
help me with I am missing in my above code? I know that what is in the
parenthesis is not right, but what is it missing?

Thanks!!

–Cory

This obviously does not work, but I am not quite sure why it does not
work. Could someone please post a basic example of a select for me, or
help me with I am missing in my above code? I know that what is in the
parenthesis is not right, but what is it missing?

Let’s pretend you have an instance of Pet in @pet and it has a “spayed”
attribute.

You could then do:

form.select(“pet”, “spayed”, [[‘Yes’, true], [‘No’, false]])

Assuming @pet.spayed was a boolean field anyway.

Not sure what the :fixed option is, but there are additional arguments
to
the method for options and html_options.

-philip

The :fixed option relates back to the column in my table. Here is the
entire form…

<% form_for :listing,
:html => { :class => “new_listing” } do |form| %>

Title of listing:
<%= form.text_field :title %>

Listing Category:
<%= form.text_field :listing_type %>

Breed of Pet:
<%= form.text_field :breed %>

Gender of Pet:
<%= form.select(Male,Female) :gender %>

Age of Pet:
<%= form.text_field :age %>

Is this pet Spayed/Neutered?
<%= form.select(Yes,No) :fixed %>

Quantity of Pets:
<%= form.text_field :quantity %>

Where are you located?
<%= form.text_field :location %>

Phone Number for Inquiries:
<%= form.text_field :phone %>

Listing Description:
<%= form.text_area(:cols="20" :rows="20") %>

<%= submit_tag %>

<% end %>

I am sure there are some other little mistakes in there, the select
was just the first one that popped up! My idea with the select was to
have the user choose Yes or No, and that would then be stored in the
table as a string. Not sure that this is the best way of accomplishing
this, but it seemed to be the ideal situation given my extremely
limited Rails knowledge! Thanks for any other help that you can
provide.

–Cory

Am I correct in saying that as it stands now, with the form posted
above, that the value of the select would be stored in the DB as a
string? The column type that I set up in my migration file is a
string. So I was thinking that their yes/no choice would be stored as
a string when the form got submitted. Am I on the right track here?

–Cory