SQLite boolean字段设立失败

SQLite boolean字段设置失败环境: ruby 1.9.3p0, rails 3.2.7?Teachaer有一个字段,man:boolean?rails g sc

SQLite boolean字段设置失败

环境: ruby 1.9.3p0, rails 3.2.7

?

Teachaer有一个字段,man:boolean

?

rails g scaffold teacher man:boolean?

db:migrate

?


SQLite boolean字段设立失败

勾选man后,更新teacher时,发现SQLite数据库中字段man并没有设置成功

查看log,set 'man' = 't' ,使用sql语句进行设置,确实不行

?

update 'teacher' set 'man' = 1 where 'id' = 2;

设置为1,成功

?

?

参数传过来的man值为1,但是在更新数据库的时候,却设置为t,肯定是rails搞的鬼,搞了半天终于找到了

?

activerecord-3.2.7\lib\active_record\connection_adapters\abstract\quoting.rb

?

打开这个文件,修改以下函数:

?

?

      def quoted_true        "'1'"      end      def quoted_false        "'0'"      end
?

?重新启动,再试试就OK了,应该可以再modle中直接重写,更简单一点

?

转载请注明:http://michael-roshen.iteye.com/blog/1675419