Prompt for select_tag

I used
<% = collection_select: category,: sector_id, @ Sectors,: id,: name,
{: prompt => “All”,: selected => @ sector}, {: id =>
‘sector_admin_select’}%>

It worked perfectly, but because I don’t need to use the model
category, I thought it was more suitable to use:

<% = select_tag: sector_admin_select,
options_from_collection_for_select (@ Sectors,: id,: name, @ sector)%>

this also works perfectly, and perhaps for the reason mentioned above
it is more suitable for this purpose, only that I would get a prompt
that I
understand that the select_tag is not possible.
I am forced to use collection_select to have a prompt option?

select_tag does not support prompt, as you have found.

Easiest workaround is probably to just prepend the option manually:

<%= select_tag(:sector_admin_select, “All” +
options_from_collection_for_select(@sectors, :id, :name, @sector)) %>

On 7 January 2011 21:03, Tim S. [email protected] wrote:

select_tag does not support prompt, as you have found.

Easiest workaround is probably to just prepend the option manually:

<%= select_tag(:sector_admin_select, “All” +
options_from_collection_for_select(@sectors, :id, :name, @sector)) %>

I’ve just tried this form but it doesn’t show anything in the page.