Change Login [Gem Devise Ruby On Rails]

2

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?

    
asked by anonymous 18.08.2017 / 02:21

2 answers

1

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

    
26.09.2017 / 06:28
0

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.

link

    
23.08.2017 / 21:11