I have several TIME columns in a PostgreSQL table that I am trying to
store times of day in. These columns allow NULL values since there
may some records where there is no time to store.
My problem is that Rails is inserting a default value into these
fields (the result of calling Time.new) regardless of the value that
is passed from a form. I am generating select tags with possible time
values, and I have added one additional one called ‘none’ which I
want to insert a NULL value. I have tried all kinds of values for
this option tag, and even tried writing a attribute_before_type_cast
function and calling it via before_save to try and reset the value to
null or nil. I have had no luck.
So I am pretty sure that I am missing something- what do I have to do
to get Rails to allow an attribute to hold a NULL value and also
allow me to insert one into the database?