Add a note about default_scope and create records

[ci skip]
This commit is contained in:
Mauro George 2015-07-02 18:58:19 -03:00
parent cc7ef0cf19
commit 2ef1de02ed

@ -1266,6 +1266,18 @@ class Client < ActiveRecord::Base
end
```
NOTE: The `default_scope` is also applied while creating/building a record.
It is not applied while updating a record. E.g.:
```ruby
class Client < ActiveRecord::Base
default_scope { where(active: true) }
end
Client.new # => #<Client id: nil, active: true>
Client.unscoped.new # => #<Client id: nil, active: nil>
```
### Merging of scopes
Just like `where` clauses scopes are merged using `AND` conditions.