2

我想选择除第一个之外的所有 id。
User.find(:all) 调用所有 id,但我怎样才能例外?

4

2 回答 2

6

通过单个查询:

User.offset(1).pluck(:id)
于 2012-06-11T10:51:35.077 回答
0

会给你除了第一个之外的所有 id

User.where(:_id.ne => User.first.id).map(&:_id)
于 2012-06-11T10:38:20.280 回答