I am very new to Rails and am using version 3.2.6. So far I have made a simple practice application that includes a datetime. In my form partial I have
<%= form_for(@item) do |f| %>
[...snip irrelevant form fields...]
<div class="field">
<%= f.label :copyright_date, %><br />
<%= f.datetime_select :copyright_date, { include_blank: true } %>
</div>
<% end %>
From the options documentation http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-date_select I was under the impression that the { include_blank: true }
portion of the datetime_select
options hash would allow me to set empty dates. However, if I have any of the date fields (but not time fields) set to the blank option, the whole thing returns nil
. I am dealing with archival data where sometimes the entire date is not known, but only a portion. I need to be able to capture all of the datetime data if it exists but leave any unknown parts blank. I thought that was what include_blank
was for, but maybe I am misinterpreting the documentation?