Forum: Ruby on Rails Nulling a nullable boolean value from the UI?

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.
Bce1d1b7c3ec7b577dcb42e254899e6b?d=identicon&s=25 michael (Guest)
on 2005-12-04 19:26
(Received via mailing list)
In my model class I have a boolean attribute which can be NULL. I'd like
to set all three possible values from the UI using radio buttons. These
radio buttons have the values "true", "false", and "" respectively. The
trouble is that Column#type_cast casts "" to false. The only way to get
a nil value out of #type_cast, is to pass in nil. Of course, that's not
what I get in the request; there the closest thing to a nil is an empty
string.

So, how are others handling this?

Michael

--
Michael Schuerig                       Face reality and stare it down
mailto:michael@schuerig.de        --Jethro Tull, Silver River Turning
http://www.schuerig.de/michael/
A2b2f4ee23989dc68529baef9cbddcd6?d=identicon&s=25 listbox (Guest)
on 2005-12-05 15:54
(Received via mailing list)
On 4-dec-2005, at 19:22, Michael Schuerig wrote:

> not
> what I get in the request; there the closest thing to a nil is an
> empty
> string.
>
> So, how are others handling this?

I do it like this.

http://julik.textdriven.com/svn/tools/rails_plugin...
init.rb
Bce1d1b7c3ec7b577dcb42e254899e6b?d=identicon&s=25 michael (Guest)
on 2005-12-05 17:04
(Received via mailing list)
On Monday 05 December 2005 15:51, Julian 'Julik' Tarkhanov wrote:
> On 4-dec-2005, at 19:22, Michael Schuerig wrote:
[snip]
> > So, how are others handling this?
>
> I do it like this.
>
> http://julik.textdriven.com/svn/tools/rails_plugin...
>/ init.rb

I considered something similar, but came down to this

http://dev.rubyonrails.org/ticket/3102

Michael

--
Michael Schuerig                                 Life is what happens
mailto:michael@schuerig.de                  While you're making plans
http://www.schuerig.de/michael/    --Kevin Gilbert, A Long Day's Life
A2b2f4ee23989dc68529baef9cbddcd6?d=identicon&s=25 listbox (Guest)
on 2005-12-05 19:40
(Received via mailing list)
On 5-dec-2005, at 17:03, Michael Schuerig wrote:

> I considered something similar, but came down to this
>
> http://dev.rubyonrails.org/ticket/3102

I hope they accept it, it's indeed more thorough. Can you add some
tests to it?



--
Julian 'Julik' Tarkhanov
me at julik.nl
This topic is locked and can not be replied to.