如何在 Devise 中跳过 validates_presence_of 封电子邮件

How to skip validates_presence_of email in Devise

我在 Rails 应用程序中使用 Devise。我成功将电子邮件更改为用户名以登录。我不希望在创建新用户时需要电子邮件。

有人知道怎么做吗?

您需要将 devise.rb 中的配置从电子邮件更改为用户名。 config.authentication_keys = [:用户名]

答案在“How To: Allow users to sign in with something other than their email address”中。