Here is the process if you have already installed ActiveAdmin with default settings and want to authenticate users with the User.is_admin field in your existing model and delete the admin_user table:
Debug rollback admin_user (if you did not use --skip-users when installing Active Admin):
rake db:migrate:down VERSION=20141205110842
Then delete these 3 files.
In routing, delete the line devise_for :admin_users, ActiveAdmin::Devise.config
In application_controller.rb add:
def authenticate_admin! if current_user && current_user.is_admin # fine else redirect_to new_user_session_path end end
In active_admin.rb:
config.authentication_method = :authenticate_admin! config.current_user_method = :current_user config.logout_link_path = :destroy_user_session_path config.allow_comments = false config.logout_link_method = :get
To configure the device to exit via :get , add to devise.rb:
config.sign_out_via = :get
Create is_admin migration:
rails g migration add_is_admin_to_user is_admin:boolean
Edit the migration as follows:
class AddIsAdminToUser < ActiveRecord::Migration def change add_column :users, :is_admin, :boolean, default: false end end
And migrate:
rake db:migrate
If on rails 4, remember to add is_admin to allow_params. In the app /admin/user.rb:
permit_params ....., :is_admin
Add administrator rights to users in the console:
u = User.find(42); u.is_admin = true; u.save
Enjoy