You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In chapter five, there is a callback hook statement to generate an authentication token upon user creation
before_create :generate_authentication_token!
This however is flawed, as there is a uniqueness validation requirement. Since validations are performed before a user save is even considered, auth_token has a value of "" (not unique) and thus generate_authentication_token is never called!
The correct hook should be before_validation :generate_authentication_token!
The text was updated successfully, but these errors were encountered:
Also, take note shoulda matchers has issues with before_validation. For now in my project, I have left the test out since it always fails, but there may be a fix/monkeypatch for it.
In chapter five, there is a callback hook statement to generate an authentication token upon user creation
before_create :generate_authentication_token!
This however is flawed, as there is a uniqueness validation requirement. Since validations are performed before a user save is even considered, auth_token has a value of "" (not unique) and thus generate_authentication_token is never called!
The correct hook should be
before_validation :generate_authentication_token!
The text was updated successfully, but these errors were encountered: