ActiveRecord where.not
When I need a IS NULL
SQL expression with ActiveRecord it is easy to avoid a SQL string fragment.
User.where(deactivated_at: nil)
But in early versions of Rails using IS NOT NULL
required a string.
User.where("deactivated_at is not null")
But modern Rails has where.not
expressions which can eliminate the string.
User.where.not(deactivated_at: nil)
Tweet