Forum: Ruby on Rails prompting to choose an item from a select box

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.
2dd904ec5981c31e7bb7a5743a53caf8?d=identicon&s=25 Bruce Balmer (brucebalmer)
on 2006-01-03 05:06
(Received via mailing list)
Hi:

Sad question, I know.  I saw it somewhere but can't rediscover it. I
have a collection_select and want to add a prompt so the dropdown
displays  "select one"

How is that done?

thanks.

bruce
C8a634a01a2c4508360874bff7fb1a7f?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-01-03 05:14
bruce balmer wrote:
> Hi:
>
> Sad question, I know.  I saw it somewhere but can't rediscover it. I
> have a collection_select and want to add a prompt so the dropdown
> displays  "select one"
>
> How is that done?
>
> thanks.
>
> bruce

<%= select('object','method',options, {:prompt => "Choose one"} %>

Make sure the 'method' attribute in your 'objects' table defaults to
NULL or this won't work.

Use a verify_presence_of :method clause in your model to make sure the
user selects something.

I also find this handy... http://api.rubyonrails.com/

_Kevin
This topic is locked and can not be replied to.