The following code works as expected, using the @the_date as the default selected date.
<%= date_select("the_date", "", :default => @the_date ) %>
However, in the case there is no date, it needs to show blanks. The following code displays blanks, but also forces the default selection to be blank even when the date is defined.
<%= date_select("patient_details[birth_date]", "", { :default => @the_date, :include_blank => true } ) %>
How do you set the default selection to a date, and to blank if the date is nil?
Working in Rails 3.07.
Thanks.
Just, :include_blank => @the_date.nil? , it should do the trick. See example below
date_select(:patient_details, :birth_date, { :default => @the_date, :include_blank=> @the_date.nil? })