如何更改 ActiveAdmin 密码?

发布于 2024-12-18 03:28:37 字数 197 浏览 3 评论 0原文

我使用 [email protected]//password 运行 ActiveAdmin,但我想要更改这些凭据。有人知道如何改变它们吗?

I got ActiveAdmin running with [email protected]//password, but I want to change these credentials. Anyone know how to change them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

赢得她心 2024-12-25 03:28:37

最好的方法是从 Rails 控制台更改它:

    admin = AdminUser.find_by_email("[email protected]")
    admin.password = "newPassword"
    admin.save

Best way to do this would be to change it from the rails console :

    admin = AdminUser.find_by_email("[email protected]")
    admin.password = "newPassword"
    admin.save
寂寞陪衬 2024-12-25 03:28:37

使用生成器安装 ActiveAdmin 时,您将在 db/migrate 文件夹中找到名为 {timestamp}_devise_create_admin_users.rb 的迁移。

找到此行并将其更改为您想要的任何内容:

AdminUser.create!(:email => '[email protected]', :password => 'password', :password_confirmation => 'password')

但请记住,这只是种子密码,并且以明文形式公开。您可能想要做的是将 Devise 控制器设置为具有密码更改操作。查看 wikiRailscast 寻求帮助。

When you install ActiveAdmin using the generator, you'll find a migration called {timestamp}_devise_create_admin_users.rb in your db/migrate folder.

Find and change this line to whatever you want:

AdminUser.create!(:email => '[email protected]', :password => 'password', :password_confirmation => 'password')

Keep in mind though, that this is just the seed password, and is being exposed as plaintext. What you might want to do is set up the Devise controllers to have a password change action. Check out the wiki and the Railscast for help.

时光沙漏 2024-12-25 03:28:37

将其添加到 app/admin/admin_users.rb 将启用编辑管理员用户的更改密码。

ActiveAdmin.register AdminUser do
  index do
    column :email
    column :current_sign_in_at
    column :last_sign_in_at
    column :sign_in_count
    default_actions
  end

  form do |f|
    f.inputs "Admin Details" do
      f.input :email
      f.input :password
    end
    f.buttons
  end  
end

Add this at app/admin/admin_users.rb will enable change password for edit admin user.

ActiveAdmin.register AdminUser do
  index do
    column :email
    column :current_sign_in_at
    column :last_sign_in_at
    column :sign_in_count
    default_actions
  end

  form do |f|
    f.inputs "Admin Details" do
      f.input :email
      f.input :password
    end
    f.buttons
  end  
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文