diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2013-03-08 08:47:38 -0500 |
---|---|---|
committer | Neeraj Singh <neerajdotname@gmail.com> | 2013-03-08 08:47:38 -0500 |
commit | 4314d2bbb20013eefef1e52b2f57316f42c3b734 (patch) | |
tree | 977ff22083e885838f834889beb562f615934198 | |
parent | 2b8a05f35fbf510907cd133616f45cae120e235f (diff) | |
download | rails-4314d2bbb20013eefef1e52b2f57316f42c3b734.tar.gz rails-4314d2bbb20013eefef1e52b2f57316f42c3b734.tar.bz2 rails-4314d2bbb20013eefef1e52b2f57316f42c3b734.zip |
fixing typo in the merging scopes section
-rw-r--r-- | guides/source/active_record_querying.md | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index da1b4fcbf9..f8823fd43a 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -1203,7 +1203,7 @@ Just like `where` clauses scopes are merged using `AND` conditions. ```ruby class User < ActiveRecord::Base scope :active, -> { where state: 'active' } - scope :inactive, -> { where state: 'active' } + scope :inactive, -> { where state: 'inactive' } end ```ruby @@ -1216,8 +1216,7 @@ will have all conditions joined with `AND` . ```ruby User.active.where(state: 'finished') -# => SELECT "users".* FROM "users" WHERE "users"."state" = 'active' AND -"users"."state" = 'finished' +# => SELECT "users".* FROM "users" WHERE "users"."state" = 'active' AND "users"."state" = 'finished' ``` If we do want the `last where clause` to win then `Relation#merge` can @@ -1235,7 +1234,7 @@ One important caveat is that `default_scope` will be overridden by class User < ActiveRecord::Base default_scope { where state: 'pending' } scope :active, -> { where state: 'active' } - scope :inactive, -> { where state: 'active' } + scope :inactive, -> { where state: 'inactive' } end User.all |