1.If you want to create a text attribute column in mysql use in ruby:
Don't write :default => "", As some version of mysql will get error
Right way is: t.text :content, :null => false, #but not :default => ""
2.The better don't use type column name.
Because if you have a column named type, the ruby will find the object of the type. But you don't use object type for this model. So there will be a wrong.
Don't write :default => "", As some version of mysql will get error
Right way is: t.text :content, :null => false, #but not :default => ""
2.The better don't use type column name.
Because if you have a column named type, the ruby will find the object of the type. But you don't use object type for this model. So there will be a wrong.
本文介绍了使用Ruby操作MySQL数据库时应注意的两个关键点:一是如何正确创建非空的文本类型字段,避免某些MySQL版本中因默认值设置不当引发错误;二是建议避免将字段命名为'type',以防与Ruby内置的对象查找机制冲突。

被折叠的 条评论
为什么被折叠?



