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

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

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

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

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

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| %>
  <p>
    Title of listing:<br />
    <%= form.text_field :title %>
  </p>
  <p>
    Listing Category:<br />
    <%= form.text_field :listing_type %>
  </p>
  <p>
    Breed of Pet:<br />
    <%= form.text_field :breed %>
  </p>
  <p>
    Gender of Pet:<br />
    <%= form.select(Male,Female) :gender %>
  </p>
  <p>
    Age of Pet:<br />
    <%= form.text_field :age %>
  </p>
  <p>
    Is this pet Spayed/Neutered?<br/>
    <%= form.select(Yes,No) :fixed %>
  </p>
  <p>
    Quantity of Pets:<br />
    <%= form.text_field :quantity %>
  </p>
  <p>
    Where are you located?<br />
    <%= form.text_field :location %>
  </p>
  <p>
    Phone Number for Inquiries:<br />
    <%= form.text_field :phone %>
  </p>
  <p>
    Listing Description:<br />
    <%= form.text_area(:cols="20" :rows="20") %>
  </p>
  <p>
    <%= submit_tag %>
  </p>
<% 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