Skip to content

Commit d61aec3

Browse files
committed
Minor doc fix related to ActiveModel::SecurePassword [ci skip]
1 parent 67d0c9e commit d61aec3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

guides/source/active_model_basics.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ the Active Model API.
416416
```ruby
417417
class Person
418418
include ActiveModel::Model
419-
420419
end
421420
```
422421

@@ -467,7 +466,7 @@ In order to make this work, the model must have an accessor named `password_dige
467466
The `has_secure_password` will add the following validations on the `password` accessor:
468467

469468
1. Password should be present.
470-
2. Password should be equal to its confirmation.
469+
2. Password should be equal to its confirmation (provided +password_confirmation+ is passed along).
471470
3. The maximum length of a password is 72 (required by `bcrypt` on which ActiveModel::SecurePassword depends)
472471

473472
#### Examples
@@ -493,6 +492,10 @@ person.valid? # => false
493492
person.password = person.password_confirmation = 'a' * 100
494493
person.valid? # => false
495494
495+
# When only password is supplied with no password_confirmation.
496+
person.password = 'aditya'
497+
person.valid? # => true
498+
496499
# When all validations are passed.
497500
person.password = person.password_confirmation = 'aditya'
498501
person.valid? # => true

0 commit comments

Comments
 (0)