Monday, March 24, 2008

Legacy MySQL Database - TinyInt

Apparently Rails typecasts MySQL tinyint's as booleans. I was working on a Rails app for a legacy database today when I realized that I couldn't pull the value out of my 'terms' column. All it would read is a true or false, and not the actual value. After a bit of research, I discovered before_type_cast accessor. So instead of using report.terms, in order to get the value out, I had to use report.terms_before_type_cast.


Short post, but I'm sure someone will have the same problem at some point and will find it helpful.



Later.

-Ralph

1 comment:

Anonymous said...

You superstar!
I was stumped on this very same problem and thats fixed it.
Thanks for taking the time and trouble to post this - appreciated.