aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_querying.md
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-12-07 00:46:06 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-12-07 00:46:06 -0200
commit23b9cc84230042aaf7f824d70e010d7678350ec3 (patch)
tree341defb7a050322abad1f3e08014f5220e759553 /guides/source/active_record_querying.md
parentcf05e5f6ea9d5d883ed510dd01531a13ff488182 (diff)
parentde75af7acc5c05c708443de40e78965925165217 (diff)
downloadrails-23b9cc84230042aaf7f824d70e010d7678350ec3.tar.gz
rails-23b9cc84230042aaf7f824d70e010d7678350ec3.tar.bz2
rails-23b9cc84230042aaf7f824d70e010d7678350ec3.zip
Merge pull request #8332 from amatsuda/ar_where_chain
Relation.where with no args can be chained with not, like, and not_like Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/relation/query_methods.rb
Diffstat (limited to 'guides/source/active_record_querying.md')
-rw-r--r--guides/source/active_record_querying.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 9620270141..c942ffe267 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -505,6 +505,20 @@ This code will generate SQL like this:
SELECT * FROM clients WHERE (clients.orders_count IN (1,3,5))
```
+### NOT, LIKE, and NOT LIKE Conditions
+
+`NOT`, `LIKE`, and `NOT LIKE` SQL queries can be built by `where.not`, `where.like`, and `where.not_like` respectively.
+
+```ruby
+Post.where.not(author: author)
+
+Author.where.like(name: 'Nari%')
+
+Developer.where.not_like(name: 'Tenderl%')
+```
+
+In other words, these sort of queries can be generated by calling `where` with no argument, then immediately chain with `not`, `like`, or `not_like` passing `where` conditions.
+
Ordering
--------