Notification texts go here Contact Us Buy Now!

Adding New Admins to Active Admin

The initial step in adding new administrators to Active Admin is to create an AdminUser record. This can be accomplished by utilizing the AdminUser model's create! method. The following code snippet demonstrates the creation of an AdminUser with the email address "admin@example.com" and the password "password":

AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password')

Alternatively, if the desired behavior is to set the password within the interface instead of sending a reset email, certain modifications can be made. Firstly, the admin_user model should be left at its default settings. Subsequently, navigate to app/admin/admin_users.rb and implement the following code:

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
      f.input :password_confirmation
    end
    f.buttons
  end
end

For those seeking to create users (devise users, table "users") within the admin panel, the following steps are recommended:

  1. $ rails generate active_admin:resource user
  2. app/admin/user.rb:
ActiveAdmin.register User do
  permit_params :email, :name, :password, :password_confirmation

  index do
    column :name
    column :email
    actions
  end

  form do |f|
    f.inputs 'User' do
      f.input :name
      f.input :email
      f.input :password
      f.input :password_confirmation
    end
    f.actions
  end
end

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.