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? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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, "<option>All</option>" + options_from_collection_for_select(@sectors, :id, :name, @sector)) %> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 7 January 2011 21:03, Tim Shaffer <timshaffer-BUHhN+a2lJ4@public.gmane.org> 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, "<option>All</option>" + > options_from_collection_for_select(@sectors, :id, :name, @sector)) %>I''ve just tried this form but it doesn''t show anything in the page. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.