[Ruby] Cannot create user from Active Admin administrator screen

less than 1 minute read

Background

rails g active_admin:resource user

Run

class DeviseCreateUsers <ActiveRecord::Migration[6.0]
  def change
    create_table :users do |t|
      
      t.string :email, null: false, default: ""
      t.string :encrypted_password, null: false, default: ""
      t.string :reset_password_token
      t.datetime :reset_password_sent_at
      t.datetime :remember_created_at
      t.timestamps null: false
    end
    add_index :users, :email, unique: true
    add_index :users, :reset_password_token, unique: true
  end
end

according to the columns of the users table

ActiveAdmin.register User do
  permit_params :email, :reset_password_token, :reset_password_sent_at, :remember_created_at
end

And write permit_params Create user (failure).png I was unable to create a user when I clicked the Create User button after filling out the form.

So after rewriting user.rb following admin_users.rb

ActiveAdmin.register User do
  permit_params :email, :password, :password_confirmation

  index do
    selectable_column
    id_column
    column :email
    column :current_sign_in_at
    column :sign_in_count
    column :created_at
    actions
  end

  filter :email
  filter :current_sign_in_at
  filter :sign_in_count
  filter :created_at

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

The display changes as follows Create user (success).png User created!