1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

fixing typo in the merging scopes section

This commit is contained in:
Neeraj Singh 2013-03-08 08:47:38 -05:00
parent 2b8a05f35f
commit 4314d2bbb2

View file

@ -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