Forum: Ruby on Rails select helper

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
(Guest)
on 2008-10-30 07:03
(Received via mailing list)
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:

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


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?
Thani A. (Guest)
on 2008-10-30 07:11
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 %>
(Guest)
on 2008-10-30 07:29
(Received via mailing list)
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>
Thani A. (Guest)
on 2008-10-30 07:43
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} %>
Thani A. (Guest)
on 2008-10-30 07:46
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
(Guest)
on 2008-10-30 20:40
(Received via mailing list)
That did it, thanks

On Oct 29, 10:43 pm, Thani A. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.