Change Login [Gem Devise Ruby On Rails]

Asked

Viewed 287 times

2

Gem Design creates a login system with email and password. How do I change the form of email login to a code, ie instead of the user login by email it enter with a number or name?

2 answers

1

Create a Migration to add the user name:

$ rails generate migration add_username_to_users username:string

Run the Migration:

$ rake db:migrate

Change the file /config/initializers/Devise.Rb by swapping :email for :username

config.authentication_keys = [ :username ]

Finally, change your view:

<li><%= f.label :username %> <%= f.text_field :username %></li>

Reference: railscasts

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.