Ok I’m not sure what I’m doing wrong, but I have a table that holds a
bunch of times, however when I don’t fill in the text box that passes
it’s input on to the variables, rails defaults to 00:00:00, which is
bad, because that’s midnight.
I’m pretty sure I’m doing somethign wrong, and I’m even thinking of
using the date_select helper and diplaying a Drop down list for Hours
and Minutes…
My question is, is there a way to default the input to NULL instead of
00:00:00 when the user leaves the text box empty, and/or will using the
date_select with :blank => true input Null if no time is selected?
Thanks!
There sure is, you could simply set the “null” attribute of the column
in MySQL to “Yes”. Therefore if there isn’t a value submitted for the
field it defaults to “null”.
I’ve done that… all the time fields are set to NULL yes…
It still puts 00:00:00
sw0rdfish wrote:
I’ve done that… all the time fields are set to NULL yes…
It still puts 00:00:00
Did you try setting a default value for the field?
sw0rdfish wrote:
Can I set the default to Null?
ACtually NySQL defaults to Null, because if I used Navicat and insert a
line, w/o putting anything in for the times, it puts Null.
I’ve since changed my text boxes to a modified version of
datetime_select called time_select that removes the date portion… I
still get 00:00:00 put in when I choose a blank time.
Can I set the default to Null?