0

I have a rails app that is using Devise perfectly in development. I have altered it, following the official Devise documentation to use a username instead of an email address. I am also using MySQL, instead of SQLite.

When logging in, in development, I can type in "admin" to login as the user "Admin". But in production, "admin" does not work and requires me to type in the case sensitive "Admin".

I'm assuming it's a different setting in my MySQL database?

4

2 回答 2

3

我在这里假设您有一个用于登录的属性,称为login. 如果是username,请使用它而不是login下面。在您的设计初始化程序中,有一个设置:

config.case_insensitive_keys = [ :email ]

改成

config.case_insensitive_keys = [ :email, :login ]

这将:

在创建或修改用户以及用于验证或查找用户时,这些密钥将被小写。默认为:电子邮件。

因此,您可能需要更新一次 Admin 的登录信息,但是如果您输入 Admin 或 admin,它将找到并进行身份验证。

于 2012-07-03T15:03:55.540 回答
0

一般来说,为了设计我们会按照以下方式做一些事情。您能否检查一下您的 AdminUser 模型中是否存在这种情况

validates :email,:presence => true,
    :format => {:with=>email_regex,:message => "not a valid email"},
    :uniqueness => {:case_sensitive => false}
于 2012-07-03T13:12:01.023 回答