Hello, there is a table that has a column TINYINT(1) called status.
Through mysql console I see its value as 1 (when is true) but if I do
this in Rails console:
Mytable.status
=> true
give me “true” rather “1”.
How could I change 1 to true using some method?
Or true to 1?
On Aug 28, 2008, at 1:08 PM, j.francisco wrote:
Or true to 1?
Is this behavior causing a problem? If so, then explain your problem
and not simply the behavior that you see.
If you look at:
http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/MysqlAdapter.html
You’ll find one possible answer:
By default, the MysqlAdapter will consider all columns of type
tinyint(1) as boolean. If you wish to disable this emulation (which
was the default behavior in versions 0.13.1 and earlier) you can add
the following line to your environment.rb file:
ActiveRecord::ConnectionAdapters::MysqlAdapter.emulate_booleans = false
You then loose all booleans because MySQL doesn't have a true Boolean
column type.
http://dev.mysql.com/doc/refman/5.1/en/other-vendor-data-types.html
-Rob
Rob B. http://agileconsultingllc.com
[email protected]
Thanks Rob, that’s enough to solve my problem.
JF
On Aug 28, 1:41 pm, Rob B. [email protected]