For those that are interested, ... the discussion in the AWDR book
that preceded that particular quote and the suggested action for
dealing with differences in underlying db storage of boolean vals:

...
# DON'T DO THIS
...
if user.supervisor
...

# INSTEAD, DO THIS
...
if user.supervisor?
...

Jeff

On Jul 27, 3:41 pm, Greg Willits <[email protected]>
wrote:
> Frederick Cheung wrote:
> > On Jul 27, 5:45 pm, Greg Willits <[email protected]>
> > wrote:
> >> I had a working 1.2 app which I have just updated to 2.3.2 -- mostly
> >> seems good so far, but the Rails technique for booleans is acting up.
> >> MySQL column = `childSensitiveCase` varchar(1) NOT NULL default '0'
> > as long as I remember, with mysql rails expects booleans to be tinyint
> > columns
>
> Well, like I say this is currently working on an instance running as
> Rails 1.2, and...
>
> AWDWR 3rd Ed pg 320:
>
>      "This form of attribute accessor looks at the column’s value. It is
> interpreted as false only if it is the number 0; one of the strings "0",
> "f", "false", or "" (the empty string); a nil; or the constant false.
> Otherwise, it is interpreted as true."
>
> To me this implies a varchar field will work.
>
> However, I changed the column to tinyint(1) and that does indeed behave
> as desired. So, I'll just change it. Thx.
>
> -- gw
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to