Forum: Ruby on Rails A question about select_tag

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.
Zhao Y. (Guest)
on 2008-12-25 10:11
I use select_tag to create a dropdown selection box:

select_tag "people", "<option>David</option><option>Mike</option>"

but I want the option value is from a variable in a controller. How can
I do this?
Hassan S. (Guest)
on 2008-12-25 18:01
(Received via mailing list)
On Thu, Dec 25, 2008 at 12:11 AM, Zhao Yi
<removed_email_address@domain.invalid> wrote:
>
> I use select_tag to create a dropdown selection box:
>
> select_tag "people", "<option>David</option><option>Mike</option>"
>
> but I want the option value is from a variable in a controller. How can
> I do this?

See the docs for `options_from_collection_for_select`.

HTH,
--
Hassan S. ------------------------ removed_email_address@domain.invalid
Nellboy (Guest)
on 2008-12-25 20:34
(Received via mailing list)
try:

select_tag 'people', options_for_select(@names)

On Dec 25, 4:00 pm, "Hassan S." <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.