Now I have one devise model, which uses email as authentication_key.
I want to add one new devise model, which uses student_id as authentication_key.
Some guide tells me to modify the configuration
"config.authentication_keys = [ :email ]" by replacing the :email with :student_id.
After modification, the first model login always fails, so I think I have to indicate different authentication_keys for the two models separately.
How should I do?
You will have to declare inside your models which are the authenitcation keys, rather than inside the devise.rb file.
class model1 < ActiveRecord::Base devise :database_authenticatable, :rememberable, :trackable, :authentication_keys => [:email]
and for your second model
class model2 < ActiveRecord::Base devise :database_authenticatable, :rememberable, :trackable, :authentication_keys => [:studentid]
also make sure that you comment out from devise.rb the config.authentication_keys settings
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