Devise authenticating with username instead of email

前端 未结 2 782
抹茶落季
抹茶落季 2020-12-08 16:09

I\'m new to Devise and have it working fine by using an email address as the authentication key. However, I have a use case which requires a username instead and I can\'t s

相关标签:
2条回答
  • 2020-12-08 16:17
    • First of all, make sure to run the migrations.

    bundle exec rake db:migrate

    • Generate the views for Devise, otherwise Devise will use the defaults.

    rails generate devise:views

    • Change the Devise/views as you want (replacing email field to username field)

    • Restart the webserver

    Hope it helps!

    0 讨论(0)
  • 2020-12-08 16:26

    In your config/initializers/devise.rb uncomment config.authentication_keys = [ :email] and change it to config.authentication_keys = [ :username ]

    Update:
    Your form's incorrect.
    Change f.email_field to f.text_field

    0 讨论(0)
提交回复
热议问题