无法登录ActiveAdmin [英] Can't login to ActiveAdmin

查看:99
本文介绍了无法登录ActiveAdmin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在登录ActiveAdmin时遇到问题。使用来自的解决方案>无法登录活动管理员。是否可以创建管理员用户?无法登录到Active Admin



我尝试在 rails控制台中运行以下内容

  user = AdminUser.new 
user.email ='abc@example.com'
user.password ='new_password'
user.save

user.save 上,它给了我以下消息:

 (0.0ms)开始事务
AdminUser存在(0.0ms)从 admin_users WHERE admin_users。 email ='abc@example.com'LIMIT 1
false
(1.0ms)回滚事务

据我了解,这无法创建记录,对吗?



我也尝试了以下解决方案:

  AdminUser.create:email => ;: ‘abc1@example.com’:password => ‘password’,:password_confirmation => 'password'

这会在控制台中显示以下消息:

 (0.0ms)开始事务
AdminUser存在(0.0ms)从 admin_users中选择1 as作为 admin_users。 email ='ss1 @ example.com'LIMIT 1
SQL(11.0ms)插入 admin_users( created_at, current_sign_in_at, current_sign_in_ip, email, encrypted_pa​​ssword, last_sign_in_at, last_sign_in_ip, remember_created_at, reset_password_sent_at, reset_password_token, sign_in_count, updated_at)值(?,?,?,?,?,?,?,?,?,?,?,?)[[ created_at ,星期二,2014年8月26日05:41:42 UTC +00:00],[ current_sign_in_at,无],[ current_sign_in_ip,无],[电子邮件, ss1@example.com],[ encrypted_pa​​ssword, $ 2a $ 10 $ zLnnk8N3wx9GRb874YjjzOHukteF / qRjWPQMFTZOr7NMepljRRqOC,[ last_sign_in_at,nil],[ last_sign_in_ip,nil],[ remember_seted_at ,nil],[ sign_in_count,0],[ upd ated_at,2014年8月26日,星期二05:41:42 UTC +00:00]]
(138.9ms)commit transaction


#< AdminUser id:3,电子邮件: ss1@example.com,加密密码: $ 2a $ 10 $ zLnnk8N3wx9GRb874YjjzOHukteF / qRjWPQMFTZOr7NM ...,reset_password_token:无,reset_password_sent_at:nil,记住_signed_at_:当前,nil,sign_in: :nil,last_sign_in_ip:无,created_at: 2014-08-26 05:41:42,updated_at: 2014-08-26 05:41:42>

编辑:



也尝试删除如下创建所有模型:

  rake db:drop:all 
rake db:create:all
rake db:migrate

但是,由于用户名或密码无效,登录仍然失败。我该如何解决呢?

解决方案

您可能已经知道了这一点……但是如果您愿意,请不要遵循ACTIVEADMIN的指南重新使用设备!

无论如何,问题在于用户必须存在在用户和AdminUsers中。第一次设置ActiveAdmin时,我没有遇到这个问题,因为我使用的指南中只是一个布尔值,您可以在其中检查或取消检查用户是否为管理员用户。 (设置起来比较困难,但更明智的处理方式。



无论如何,您只需要转到Rails控制台即可,而不是这样:

  AdminUser.create:email =>'abc1@example.com',:password =>'password',:password_confirmation => ;'password'

.. do这样做:

  User.create:email =>'abc1@example.com',:password =>'password',:password_confirmation =>'password'

问题已解决!


I'm facing issues logging in to ActiveAdmin. Using solutions from Can't log into Active Admin. Any way to create an admin user? and Cant login to Active Admin,

I tried running the following in my rails console

user = AdminUser.new
user.email = 'abc@example.com'
user.password = 'new_password'
user.save

On user.save, it gives me the following message:

(0.0ms)  begin transaction
AdminUser Exists (0.0ms)  SELECT 1 AS one FROM "admin_users" WHERE "admin_users"."email" = 'abc@example.com' LIMIT 1
false
(1.0ms)  rollback transaction

As far as I understand, this failed to create the record, correct?

I also tried the following solution:

AdminUser.create :email => 'abc1@example.com', :password => 'password', :password_confirmation => 'password'

This gives the following message in the console:

    (0.0ms)  begin transaction
AdminUser Exists (0.0ms)  SELECT 1 AS one FROM "admin_users" WHERE "admin_users"."email" = 'ss1@example.com' LIMIT 1
SQL (11.0ms)  INSERT INTO "admin_users" ("created_at", "current_sign_in_at", "current_sign_in_ip", "email", "encrypted_password", "last_sign_in_at", "last_sign_in_ip", "remember_created_at", "reset_password_sent_at", "reset_password_token", "sign_in_count", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)  [["created_at", Tue, 26 Aug 2014 05:41:42 UTC +00:00], ["current_sign_in_at", nil], ["current_sign_in_ip", nil], ["email", "ss1@example.com"], ["encrypted_password", "$2a$10$zLnnk8N3wx9GRb874YjjzOHukteF/qRjWPQMFTZOr7NMepljRRqOC"], ["last_sign_in_at", nil], ["last_sign_in_ip", nil], ["remember_created_at", nil], ["reset_password_sent_at", nil], ["reset_password_token", nil], ["sign_in_count", 0], ["updated_at", Tue, 26 Aug 2014 05:41:42 UTC +00:00]]
(138.9ms)  commit transaction


#<AdminUser id: 3, email: "ss1@example.com", encrypted_password: "$2a$10$zLnnk8N3wx9GRb874YjjzOHukteF/qRjWPQMFTZOr7NM...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: "2014-08-26 05:41:42", updated_at: "2014-08-26 05:41:42">

EDIT:

Also tried dropping and creating all models as follows:

rake db:drop:all
rake db:create:all
rake db:migrate

However, it still fails to login because of invalid username or password. How do I fix this?

解决方案

You probably already figured this out... but DON'T FOLLOW ACTIVEADMIN'S GUIDE IF YOU'RE USING DEVISE! It's not gonna work... (They REALLY need to revise their Readme... it's been... YEARS.)

Anyway the problem is that the user MUST exist in both Users and AdminUsers. I didn't have this problem when I setup ActiveAdmin the first time because there was simply a boolean in the guide I was using where you could check or uncheck if a user was an admin user or not. (It was more difficult to setup but a MUCH more sensible way of doing things.

Anyway you just need to go to a rails console and instead of this:

AdminUser.create :email => 'abc1@example.com', :password => 'password', :password_confirmation => 'password'

..do THIS:

User.create :email => 'abc1@example.com', :password => 'password', :password_confirmation => 'password'

Problem solved!

这篇关于无法登录ActiveAdmin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆