WhereChain objects act as placeholder for queries in which where does not have any parameter. In this case, where must be chained with not to return a new relation.

Methods
N
Class Public methods
new(scope)
   # File activerecord/lib/active_record/relation/query_methods.rb
20 def initialize(scope)
21   @scope = scope
22 end
Instance Public methods
not(opts, *rest)

Returns a new relation expressing WHERE + NOT condition according to the conditions in the arguments.

not accepts conditions as a string, array, or hash. See QueryMethods#where for more details on each format.

User.where.not("name = 'Jon'")
# SELECT * FROM users WHERE NOT (name = 'Jon')

User.where.not(["name = ?", "Jon"])
# SELECT * FROM users WHERE NOT (name = 'Jon')

User.where.not(name: "Jon")
# SELECT * FROM users WHERE name != 'Jon'

User.where.not(name: nil)
# SELECT * FROM users WHERE name IS NOT NULL

User.where.not(name: %w(Ko1 Nobu))
# SELECT * FROM users WHERE name NOT IN ('Ko1', 'Nobu')
   # File activerecord/lib/active_record/relation/query_methods.rb
44       def not(opts, *rest)
45         opts = sanitize_forbidden_attributes(opts)
46 
47         where_clause = @scope.send(:where_clause_factory).build(opts, rest)
48 
49         @scope.references!(PredicateBuilder.references(opts)) if Hash === opts
50 
51         if not_behaves_as_nor?(opts)
52           ActiveSupport::Deprecation.warn(<<~MSG.squish)
53             NOT conditions will no longer behave as NOR in Rails 6.1.
54             To continue using NOR conditions, NOT each conditions manually
55             (`#{ opts.keys.map { |key| ".where.not(#{key.inspect} => ...)" }.join }`).
56           MSG
57           @scope.where_clause += where_clause.invert(:nor)
58         else
59           @scope.where_clause += where_clause.invert
60         end
61 
62         @scope
63       end