查找不区分大小写的电子邮件在 Devise 中不起作用
Finding case-insensitive emails does not work in Devise
基于 initializers/devise.rb
中的以下配置:
# Configure which authentication keys should be case-insensitive.
# These keys will be downcased upon creating or modifying a user and when used
# to authenticate or find a user. Default is :email.
config.case_insensitive_keys = [:email]
"find a user"是什么意思?做的时候是:
User.find_by(email: "UsEr@ExampLe.com")
因为当我在数据库中有一个电子邮件为 "user@example.com"
的用户时,returns 无效。
我正在使用 rails 5 和 Devise 4.2.0
请注意 User.find_by(email: params[:email])
区分大小写。请改用 User.find_for_authentication(email: params[:email])
。参见 docs
基于 initializers/devise.rb
中的以下配置:
# Configure which authentication keys should be case-insensitive.
# These keys will be downcased upon creating or modifying a user and when used
# to authenticate or find a user. Default is :email.
config.case_insensitive_keys = [:email]
"find a user"是什么意思?做的时候是:
User.find_by(email: "UsEr@ExampLe.com")
因为当我在数据库中有一个电子邮件为 "user@example.com"
的用户时,returns 无效。
我正在使用 rails 5 和 Devise 4.2.0
请注意 User.find_by(email: params[:email])
区分大小写。请改用 User.find_for_authentication(email: params[:email])
。参见 docs