Blank option with select tag

Anybody know how to add a Blank option to a select_tag. This is what I have now

<%= select_tag "province","<option></option>                          <option>Prince Edward Island</option>                          <option>New Brunswick</option>                          <option>Nova Scotia</option>                          <option>Newfoundland</option>"             %>

This is the output I would like <select name="province"><option value="">All</option>                          <option value="Prince Edward Island">Prince Edward Island</option>                          <option value="New Brunswick">New Brunswick</

                         <option value="Nova Scotia">Nova Scotia</

                         <option value="Newfoundland">Newfoundland</

Anybody know how to add a Blank option to a select_tag. This is what I have now

add as an option... :include_blank => true

-philip

Thanks but how do I add that into the code. I tried:

<%= select_tag "province","<option ></option>                          <option>Prince Edward Island</option>                          <option>New Brunswick</option>                          <option>Nova Scotia</option>                          <option>Newfoundland</option> :include_blank => true" %>

I am a newbie so please excuse me.

Hi Sean,

Why don't you put those options in, then?

Julian

Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) NEW VIDEO
(#2) OUT NOW! http://sensei.zenunit.com/

How about something like this:

provinces = ["", "Prince Edward Island", "New Brunswick", "Nova Scotia", ...] province_collection = provinces.collect{|province| [province, province]} province_options = options_for_select(province_collection)

<%= select_tag :province, province_options %>

The first three lines could/should be in the controller (in which case province_options would need to be an instance variable @province_options). I've broken them down just for the sake of clarity; you could easily enough chain things together. The first line just creates an array of strings of province names and the second line creates a new array that will look like this [['', ''], ['PEI', 'PEI'], ...] options_for_select (third line) takes that array and converts it into a string of option tags that is suitable for use with your select_tag.