Roy*_*Roy 25 authentication models devise ruby-on-rails-3
现在我有一个设计模型,它使用email作为authentication_key.
我想添加一个新的设计模型,它使用student_id作为authentication_key.
一些指南告诉我修改配置
"config.authentication_keys = [:email]"通过将:email替换为:student_id.
修改后,第一个模型登录总是失败,所以我想我必须分别为两个模型指出不同的authentication_keys.
我应该怎么做?
Dim*_*ris 79
您必须在模型内部声明authenitcation键,而不是在devise.rb文件中.
class model1 < ActiveRecord::Base
devise :database_authenticatable, :rememberable, :trackable, :authentication_keys => [:email]
Run Code Online (Sandbox Code Playgroud)
并为您的第二个模型
class model2 < ActiveRecord::Base
devise :database_authenticatable, :rememberable, :trackable, :authentication_keys => [:studentid]
Run Code Online (Sandbox Code Playgroud)
还要确保从devise.rb注释掉config.authentication_keys设置
| 归档时间: |
|
| 查看次数: |
6259 次 |
| 最近记录: |