How to get a default blank for select_date?

I'm trying to get a blank date as the default when using the
select_date helper as follows:

select_date Date.today, :prefix => 'startdate', :order =>
[:month, :day, :year], :include_blank => true

This gives me the current date as the default. It is my understanding
(or misunderstanding) that adding the :include_blank => true will
default the values to blanks. But it doesn't seem to be doing that.
Although including this option does allow me to select a blank value.
Just not defaulting to blanks, which is what I'm trying to accomplish.

Thanks in advance for any help.

Steve

Instead of Date.today, pass in nil. As long as :include_blank = true option is present, the default date will be blank.

I was thinking I had to put a nil there but didn't managed to figure
out how to do it. I was using a plain "" which didn't work obviously.
I didn't think of just using the nil variable.

Anyhow it worked.

Thank you so much.

FWIW--this is working for me:

  f.date_select :start_date, :include_blank => true, :order => [:day,
:month, :year]

Not sure if the difference is the order of the args, or the fact that
I'm calling date_select vs. your select_date. (What's the difference
between those 2 helpers?)

HTH,

-Roy

I believe date_select requires that you specify an object and the
method as in:
date_select(object_name, method, options={})

whereas select_date only needs a variable such as:
  select_date( variable, option={})

when you use f.date_select you have already defined the object
beforehand, ( Example: <% form_for @object do |f| ), and hence
your :start_date is the method for your object f. You get the blank
result because your :start_date is presumably nil in the beginning.

Not sure of that answers your question or make it more confusing. :slight_smile:

Steve