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?
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.
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.
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.