Answer the question
In order to leave comments, you need to log in
How to completely remove email validation in devise?
The goal is to get rid of the default devise settings, namely, to replace authorization by email with authorization by another parameter (: username in my case).
What I did: Inserted the parameter I needed into config.authentication_keys .
Removed the :validatable setting from the user model.
Replaced all parameters from email to username in views.
However, after all these steps, I get this error when I try to register a new user:
The email address must contain the @ symbol .
This is strange, because validation has been disabled.
Answer the question
In order to leave comments, you need to log in
In general, if you do not need an email, then using the device is not particularly justified.
There are other, more flexible gems for such cases
https://github.com/NoamB/sorcery
https://github.com/binarylogic/authlogic
Usually, if an email is not needed, it is automatically generated by type, for example [email protected] com
Moreover, sometime it may still be needed, so cutting it out completely is a bit doubtful.
If you still really want to, you can take a look at the validatable itself:
https://github.com/plataformatec/devise/blob/maste...
Apparently, you need to add to the user:
def email_required?
false
end
def email_changed?
false
end
change_column :users, :email, :string, :null => true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question