Gem devise creates a login system with email and password. How do I change the email login form to a code, that is, instead of the user logging in via email, he or she enters a number or name?
Gem devise creates a login system with email and password. How do I change the email login form to a code, that is, instead of the user logging in via email, he or she enters a number or name?
Create a migration to add the username:
$ rails generate migration add_username_to_users username:string
Run a migration:
$ rake db:migrate
Change the file /config/initializers/devise.rb by exchanging: email by: username
config.authentication_keys = [ :username ]
Finally, change your view:
<li><%= f.label :username %> <%= f.text_field :username %></li>
Reference: railscasts
I have not yet had to do this, but there is this devise wiki that demonstrates how to use username
(or code) to log in.