aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2013-02-20 18:35:31 +0100
committerXavier Noria <fxn@hashref.com>2013-02-20 20:37:00 +0100
commit6b42e0fe250765110334ec6aff32a79c615f8a05 (patch)
treeb57ffcb825f736926edf8e438b317af8bb74a8d3 /activerecord
parentc5115b06d7e7ccc5f1d826ed90cf9ee92b1c49a8 (diff)
downloadrails-6b42e0fe250765110334ec6aff32a79c615f8a05.tar.gz
rails-6b42e0fe250765110334ec6aff32a79c615f8a05.tar.bz2
rails-6b42e0fe250765110334ec6aff32a79c615f8a05.zip
adds an example in the docs of #not with multiple conditions [ci skip]
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 5358b43728..011839c05d 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -11,11 +11,11 @@ module ActiveRecord
@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 @@ module ActiveRecord
#
# 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