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
Kevin Olbrich
2006-Jan-03 04:14 UTC
[Rails] Re: prompting to choose an item from a select box
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 -- Posted via http://www.ruby-forum.com/.