I set up Devise to log in with a username instead of email address because a significant number of our users share the same email address with their spouse. It is a unique market that we serve. But each spouse needs separate accounts to record personality instrument results.
The database no longer requires a unique email address so it will accept the same email addy for two accounts. However, Devise is still requiring a unique email address for each account. Is there a setting or a work around that i can use to change this?
= User Model
def email_required?
false
end
def email_changed?
false
end
# For ActiveRecord 5.1+
def will_save_change_to_email?
false
end
= Migration
rails g migration update_index_on_users
def up
sql = 'DROP INDEX index_users_on_email'
sql << ' ON users' if Rails.env == 'production' # Heroku pg
ActiveRecord::Base.connection.execute(sql)
end
Look in the config/initializers/devise.rb
. You can change the default authentication key, which by default is :email
to be anything you want, for example:
config.authentication_keys = [ :username ]
Please find the instructions here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With