新手问题 model 查找

xiaoxiao · 2013年09月02日 · 最后由 xiaoxiao 回复于 2013年09月03日 · 2014 次阅读

model User 的一个字段是 usertype(用户类型)有以下可能:student(学生)teacher(老师)headermaster(校长)现在我想得到所有学生的数据如下 User.where(:usertype=>'student')

现在我想得到所有非学生的数据怎么写 。。。。

User.where("usertype != 'student'")

User.where(:usertype.ne => 'student'), mongo?

!= 的话不能用到索引,建议用 in

需要 登录 后方可回复, 如果你还没有账号请 注册新账号