ActiveAdmin有条件地显示列

时间:2015-08-11 14:58:37

标签: ruby-on-rails ruby ruby-on-rails-4 activeadmin

有关如何使用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

1 个答案:

答案 0 :(得分:8)

您可以这样做:

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