2

I am new to Ruby on Rails. I am using ActiveAdmin for administration purposes.

I have Googled a lot about "how to manage admin users" for example, changing default username password from admin@example.com and password to something else. Or how to add additional admin users and giving them specific rights to specific admin users.

I would really appreciate any help/tips you can provide that can get me started.

Moon
  • 119
  • 1
  • 6

1 Answers1

4

You just have to register AdminUser as a manageable resource:

$> rails generate active_admin:resource AdminUser

Then, just customize the whole thing but remember that both 'password' and 'password_confirmation' field have to be present in the form if you want to be able to manipulate passwords - you decide if that's a good idea. I did it like this but you're more than welcome to do anything you please:

ActiveAdmin.register AdminUser do

  filter :email

  index do
    id_column
    column :email
    column :last_sign_in_at
    column :created_at
    default_actions
  end

  show :title => :email do
    panel 'Admin Details' do
      attributes_table_for admin_user, :email, 
                                       :last_sign_in_at, 
                                       :last_sign_in_ip,
                                       :created_at, 
                                       :sign_in_count
    end
    active_admin_comments
  end

  form do |f|
    f.inputs 'Details' do
      f.input :email
      f.input :password
      f.input :password_confirmation
    end
    f.buttons
  end

end

If you need inspiration, look at the demo app provided by gregbell on GitHub.