diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-07 00:46:06 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-07 00:46:06 -0200 |
commit | 23b9cc84230042aaf7f824d70e010d7678350ec3 (patch) | |
tree | 341defb7a050322abad1f3e08014f5220e759553 /guides | |
parent | cf05e5f6ea9d5d883ed510dd01531a13ff488182 (diff) | |
parent | de75af7acc5c05c708443de40e78965925165217 (diff) | |
download | rails-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')
-rw-r--r-- | guides/source/active_record_querying.md | 14 |
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 -------- |