Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveAdmin conditionally displaying columns

Any thoughts on how to conditionally display columns with the ActiveAdmin DSL?

index do
    selectable_column
    id_column
    column :name
    column :address, if: current_user.admin?
    column :phone
    column :role
    column :created_at
    column :updated_at
    actions
  end
like image 771
Drew Avatar asked Jan 07 '23 19:01

Drew


1 Answers

You can do something like this:

index do
    selectable_column
    id_column
    column :name
    if current_user.admin?
      column :address
    end
    column :phone
    column :role
    column :created_at
    column :updated_at
    actions
 end
like image 127
dreamingblackcat Avatar answered Jan 19 '23 04:01

dreamingblackcat