diff options
author | Xavier Noria <fxn@hashref.com> | 2013-02-20 18:35:31 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2013-02-20 20:37:00 +0100 |
commit | 6b42e0fe250765110334ec6aff32a79c615f8a05 (patch) | |
tree | b57ffcb825f736926edf8e438b317af8bb74a8d3 /activerecord/lib/active_record/relation/query_methods.rb | |
parent | c5115b06d7e7ccc5f1d826ed90cf9ee92b1c49a8 (diff) | |
download | rails-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/lib/active_record/relation/query_methods.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 12 |
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 |