Prompting to choose an item from a select box


#1

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


#2

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