Select helper


#1

I am trying to figure out how to use the “select” helper in changing a
scaffold produced “new.html.erb” file. Specifically how do I change:

    Year In School: <%= f.text_field :year %>

so that this shows up as a “drop down box”.

I’ve tried different variations of

<%= f.select :year %>

but that never works.
Any help?


#2

removed_email_address@domain.invalid wrote:

I am trying to figure out how to use the “select” helper in changing a
<%= f.select :year %>

but that never works.
Any help?
try this

<%= f.select :year ,Time.now.year-100…Time.now.year %>


#3

Nope, that doesn’t work. To clarify, the year part is supposed to be a
pull down select menu of “Senior, Junior, Sophomore, Freshman”

On Oct 29, 10:11 pm, Thani A. removed_email_address@domain.invalid


#4

Thani A. wrote:

removed_email_address@domain.invalid wrote:

Nope, that doesn’t work. To clarify, the year part is supposed to be a
pull down select menu of “Senior, Junior, Sophomore, Freshman”

On Oct 29, 10:11�pm, Thani A. removed_email_address@domain.invalid
post here “new.html.erb” content


#5

That did it, thanks

On Oct 29, 10:43 pm, Thani A. removed_email_address@domain.invalid


#6

removed_email_address@domain.invalid wrote:

Nope, that doesn’t work. To clarify, the year part is supposed to be a
pull down select menu of “Senior, Junior, Sophomore, Freshman”

On Oct 29, 10:11�pm, Thani A. removed_email_address@domain.invalid

what is the error ? post it here.
what is your rails version?

and try this
<%= select :obj,:year ,%w{Senior Junior Sophomore Freshman} %>