This works in some (most ?) cases but bear in mind that this ignores any password complexity/validation rules that may be in place. My preference is to repeatedly attempt to generate a password from a set of predefined characters (e.g. alphanumeric, symbols) using Devse.password_length.min and Devise.password_regex.
Just be sure to set some limit on how many attempts it will make to avoid infinite loops if the seed character set is insufficient to satisfy the complexity requirements.
This works in some (most ?) cases but bear in mind that this ignores any password complexity/validation rules that may be in place. My preference is to repeatedly attempt to generate a password from a set of predefined characters (e.g. alphanumeric, symbols) using
Devse.password_length.min
andDevise.password_regex
.Just be sure to set some limit on how many attempts it will make to avoid infinite loops if the seed character set is insufficient to satisfy the complexity requirements.