En Rails 4 puedes usar User.where.not(id: [])
que le dará el resultado correcto. Produce:
SELECT "users".* FROM "users" WHERE (1 = 1)
Desafortunadamente User.where('id NOT IN (?)', [])
debería ser equivalente pero no lo es. Todavía te da el resultado incorrecto:
SELECT "users".* FROM "users" WHERE (id NOT IN (NULL))
Referencias:
- https://github.com/rails/rails/issues/778
- https://github.com/rails/arel/commit/cbff1bcf
- https://github.com/rails/rails/pull/8332
- https://github.com/rails/rails/commit/8d02afeaee8993bd0fde69687fdd9bf30921e805