rails/rails — pull request #7217 by freerobby (2012-07-31 20:22:16+00:00)
Title: has_secure_password should not raise a 'digest missing' error if the calling class has specified for validations to be skipped.

A pull request was recently merged that allows the has_secure_password to bypass the included password validations. See: https://github.com/rails/rails/commit/0e1e527654f286452fa6f86f5d229f278435319a

However, the same commit raises an explicit error if the password_digest is blank even if validations are disabled. I have altered this behavior to raise the error only if validations are enabled.

An example where the existing version is undesirable is if a user account model is created after an oauth sign in. In that case, a user may be created from Twitter/Facebook/Google/etc. credentials without ever creating a password. I believe this use case should work by default and not require catching an exception.