无法登录Active Admin。有什么办法创建管理员用户?

无法登录Active Admin。有什么办法创建管理员用户?

问题描述:

当我尝试使用默认的admin用户登录时,我收到无效的电子邮件或密码。是否可以使用代码创建用户并尝试登录?

When I try to log in with the default admin user, I get "invalid email or password." Is there a way to create a user with code and try to log in that way?

我可以登录实时网站,但不能登录本地网站。我的开发代码与生产环境完全匹配。

I can log in on my live website, but not locally. My development code matches exactly what is on production.

您可以在开发服务器上运行 rails控制台,然后在控制台本身中创建一个新的管理员用户。

You can run a rails console on your development server, and create a new admin user in the console itself.

以下是此类命令的典型顺序(根据您的设置进行更改):

The following is a typical sequence of such commands (change them according to your setup):

user = AdminUser.new
user.email = "<your email>"
user.password = "<your password>"
user.save

这将为您创建所需的管理员。 :)

That will create the required admin for you. :)