Create an ActiveAdmin account by Cloning a Devise User account
Need to create an admin account for ActiveAdmin but don't want to go through account creation and password re-entry twice? Use this method to get the job done.
def new_admin_user_from_devise(user_id)
user = User.find(user_id)
unwanted = ["id", "sign_in_count", "created_at", "updated_at", "current_sign_in_at", "last_sign_in_at", "current_sign_in_ip", "last_sign_in_ip"]
AdminUser.new(
AdminUser.column_names.map {|i|
{ i => user[i] }
}.inject(:update).except(unwanted)
).save(validate: false)
end
This copies your already encrypted password account over. Works great!
Written by Daniel P. Clark
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#