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.
Cee2168acd7a6d8d097962b82b914557?d=identicon&s=25 railsfid@gmail.com (Guest)
on 2008-10-30 06: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?
C5c0e0499446b84fd3bcc61cf7862539?d=identicon&s=25 Thani Ararsu (thaniyarasu)
on 2008-10-30 06:11
railsfid@gmail.com 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 %>
Cee2168acd7a6d8d097962b82b914557?d=identicon&s=25 railsfid@gmail.com (Guest)
on 2008-10-30 06: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 Ararsu <rails-mailing-l...@andreas-s.net>
C5c0e0499446b84fd3bcc61cf7862539?d=identicon&s=25 Thani Ararsu (thaniyarasu)
on 2008-10-30 06:43
railsfid@gmail.com 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 Ararsu <rails-mailing-l...@andreas-s.net>

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

and try this
<%= select :obj,:year ,%w{Senior Junior Sophomore Freshman} %>
C5c0e0499446b84fd3bcc61cf7862539?d=identicon&s=25 Thani Ararsu (thaniyarasu)
on 2008-10-30 06:46
Thani Ararsu wrote:
> railsfid@gmail.com 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 Ararsu <rails-mailing-l...@andreas-s.net>
post here "new.html.erb" content
Cee2168acd7a6d8d097962b82b914557?d=identicon&s=25 railsfid@gmail.com (Guest)
on 2008-10-30 19:40
(Received via mailing list)
That did it, thanks

On Oct 29, 10:43 pm, Thani Ararsu <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.