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? Thanks.
on 2006-01-31 02:06
on 2006-01-31 16:15
You have to do it by hand. At present, rails does not respect nulls for any but numeric data. http://dev.rubyonrails.org/ticket/3301 Seems pretty basic. This is 1.0, though... On 1/31/06, Jim B. <firstname.lastname@example.org> wrote: > function and calling it via before_save to try and reset the value to > http://lists.rubyonrails.org/mailman/listinfo/rails > -- "Her faults were those of her race and sex; her virtues were her own. Farewell, and if for ever - " -- "Travels with a Donkey in the Cevennes" by Robert Louis Stevenson