Found the answer in the source for actionpack-1.13.2/lib/action_view/
helpers/form_options_helper.rb
the :prompt option can take a value that goes atop ->
<%= collection_select :task, :id, Task.find(:all), :id,
"type_name",
{ :prompt => ''--- any ---'' } %>
On Apr 30, 5:43 pm, sbeam <szb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Say I have a normal <SELECT> tag being generated thusly:
>
> <%= collection_select :task, :id, Task.find(:all), :id, :name %>
>
> what is the easiest way to add a "ANY" option to the top of the
option
> list? I know Task.find(:all) returns a collection object, so is there
> a unshift() for that?
>
> well OK I tried:
>
> Task.find(:all).unshift([:id=>0,
:name=>''ANY''])
>
> but that is just a vanilla Array with "undefined method
`name''"....?
>
> thanks
> Sam
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---