新手问题 表示模型少量不同状态的数据类型,求经验

kikyous · August 15, 2012 · Last by fleuria replied at August 15, 2012 · 1940 hits

有两个状态: 已激活和未激活

数据库中我是用 integer 1 和 0 表示这两个状态,然后在 view 中用 helper 转换呢?

还是直接存储汉字 已激活 或 未激活?

哪种好?

应该用 boolean 吧?

尽量用 state machine 吧 https://github.com/pluginaweek/state_machine/

如果不复杂,存字符串其实也挺好的,翻数据的时候好看。

You need to Sign in before reply, if you don't have an account, please Sign up first.