新手问题 model 查找

xiaoxiao · September 02, 2013 · Last by xiaoxiao replied at September 03, 2013 · 2015 hits

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

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

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

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

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

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