Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adds an example in the docs of #not with multiple conditions [ci skip]

  • Loading branch information...
commit 6b42e0fe250765110334ec6aff32a79c615f8a05 1 parent c5115b0
@fxn fxn authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 activerecord/lib/active_record/relation/query_methods.rb
View
12 activerecord/lib/active_record/relation/query_methods.rb
@@ -11,11 +11,11 @@ def initialize(scope)
@scope = scope
end
- # Returns a new relation expressing WHERE + NOT condition
- # according to the conditions in the arguments.
+ # Returns a new relation expressing WHERE + NOT condition according to
+ # the conditions in the arguments.
#
- # #not accepts conditions in one of these formats: String, Array, Hash.
- # See #where for more details on each format.
+ # +not+ accepts conditions as a string, array, or hash. See #where for
+ # more details on each format.
#
# User.where.not("name = 'Jon'")
# # SELECT * FROM users WHERE NOT (name = 'Jon')
@@ -31,6 +31,10 @@ def initialize(scope)
#
# User.where.not(name: %w(Ko1 Nobu))
# # SELECT * FROM users WHERE name NOT IN ('Ko1', 'Nobu')
+ #
+ # User.where.not(name: "Jon", role: "admin")
+ # # SELECT * FROM users WHERE name != 'Jon' AND role != 'admin'
+ #
def not(opts, *rest)
where_value = @scope.send(:build_where, opts, rest).map do |rel|
case rel
Please sign in to comment.
Something went wrong with that request. Please try again.