Conrad T. wrote:
On Mon, Jul 27, 2009 at 5:06 PM, Jeff L. [email protected]
On Jul 27, 5:45 pm, Greg W. [email protected]
AWDWR 3rd Ed pg 320:
Greg, if you’re referencing AWDwR 3ed, then you must have read the
17.1 which explains the mappings between Ruby symbols and the underlying
database in regards to migrations.
Sure, but… (to clarify how I drew my conclusions)
That describes what a migration will create–which could be independent
of how the accessor works. IOW, it doesn’t necessarily imply that
tinyint(1) is the only valid field type on which the ? accessor will
work. In fact, that’s exactly what I am saying, the rest of the text in
the book which covers this topic specifically implies that a character
field will work.
The entire quote:
To query a column as a boolean value in a condition, we must append a
tion mark to the columnâ€™s name:
INSTEAD, DO THIS
user = Users.find_by_name(“Dave”)
This form of attribute accessor looks at the columnâ€™s value. It is
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
This happens to be the exact same text from the 2nd Edition, and this
behavior is true for 1.2 – a MySQL varchar(1) does behave with the
expected true/false results with string values in the column as the text
above describes. But for 2.3 it must be a tinyint(1) and obviously only
the 0 and 1 values are usable.
Anyway, not a big deal. I changed the field type, and I added an Errata
to the pragprog web site for the book.