I know its not kindly looked upon for using enum w/ mysql, but how
would I do this using the rails migration? or is it even possible? I
can’t seem to find this on any sites/books about rails migration. I
was simply wanting 2 options of ‘Y’,‘N’
Ah, but how I love RoR… today was my first ‘real’ day outside of
tutorials. And glad to just be joining the group!
I know its not kindly looked upon for using enum w/ mysql, but how
would I do this using the rails migration? or is it even possible? I
can’t seem to find this on any sites/books about rails migration. I
was simply wanting 2 options of ‘Y’,‘N’
Sadly it does not, and the MySQL way to do boolean is to use enumerate
Y/N,
or at least that’s the use I saw most suggested when I was first
starting to
learn to use MySQL databases. The easiest way to handle this would
honestly
be to convert your enum columns into single bit integers (Integer :size
=>
1). But this may not be an option to you depending on who controls the
data. Your only other option, I believe, would be to either write, or
find,
a ror to mysql driver that converts all boolean requests to the database
from 1/0 to Y/N.
Booleans are a tricky thing to work with in RoR. The idea is to make
your
application database agnostic, but because of certain quirks, e.g.
Oracle
and mysql databases not having boolean options, it’s a little hard to
reach
RoR nirvana. The accepted practice seems to be to use single bit
integers,
which is why I suggested the change.
Sadly it does not, and the MySQL way to do boolean is to use enumerate
Y/N,
MySQL doesn’t have a native boolean type, but it will silently convert
columns declared boolean to tinyint(1), which Rails recognizes as
de-facto
boolean.
application database agnostic, but because of certain quirks, e.g. Oracle
and mysql databases not having boolean options, it’s a little hard to reach
RoR nirvana. The accepted practice seems to be to use single bit integers,
which is why I suggested the change.
Makes sense to me to do any required conversion in the connection
adapter -
also explains why check_box returns 0 and 1 instead of the (to me) more
intuitive true/false.
I’ll give that a go right now. It would be nice if rails could detect
true / false with the options instead of declaring 1=true 0=false (or
maybe it can and I don’t know about it
and mysql databases not having boolean options, it’s a little hard to
–
Rasputin :: Jack of All Trades - Master of Nuns http://number9.hellooperator.net/