Forum: Ruby on Rails Storing a NULL value from a radio_button

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C7d5bc5b054035d95f287797c2595694?d=identicon&s=25 Matias (Guest)
on 2006-05-31 20:34
(Received via mailing list)
Hi, I've a boolean database field (tinyint(1)) wich allows nulls.

Then, I've something like this:
radio_button('server','customer_has_login',"NULL")
radio_button('server','customer_has_login',true)
radio_button('server','customer_has_login',false)

The problem is with the 1st radio_button, it doesn't store a null.
I've tried with no luck:

radio_button('server','customer_has_login',"nil")
and
radio_button('server','customer_has_login',nil)

no way..... any idea??? is possible??

Thanks.
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2006-05-31 21:09
(Received via mailing list)
Hi Matias,

Matias wrote:

> Hi, I've a boolean database field (tinyint(1)) wich allows
> nulls.
>
> Then, I've something like this:
> radio_button('server','customer_has_login',"NULL")
> radio_button('server','customer_has_login',true)
> radio_button('server','customer_has_login',false)
>
> The problem is with the 1st radio_button, it doesn't store a null.
> I've tried with no luck:

>From a human factors perspective, it makes no sense to present a user with
an option to select from true, false, or NULL.  From a CS perspective,
booleans are for two-option choices, not three-option choices.  You
haven't
said what you're trying to accomplish, so I'm guessing here, but if you
want
to set the initial value to NULL you'd do it in your database
definition.
If you're looking for something else, like trying to allow the user to
tell
you "I don't know", then change your field definition to varchar(7) and
put
'true', 'false', or 'unknown' in it.

hth,
Bill
C7d5bc5b054035d95f287797c2595694?d=identicon&s=25 Matias (Guest)
on 2006-05-31 21:13
(Received via mailing list)
Thanks,

I think I'm going to change the column type to char(1) and use simple
characters instead.

Thanks.
This topic is locked and can not be replied to.