11

ActiveAdmin 中的默认显示页面是一个表,每行一个属性。对于我的后端,这很好,除了我想隐藏 id、created_at、updated_at 等字段。

是否有可能以类似于索引页面的方式做到这一点,即通过明确列出所需的属性,同时让 AtiveAdmin 处理布局?

文档中显示的唯一示例表明,要自定义显示页面,您必须完全接管并编写部分或 arbre 构造。

谢谢!

4

3 回答 3

25

I think you're looking for attributes_table:

show do
  attributes_table :name, :content
end

See https://github.com/gregbell/active_admin/blob/master/lib/active_admin/views/pages/show.rb if you're curious.

(I completely removed my prior answer because it was basically useless!)

于 2011-09-23T14:12:53.860 回答
2
show do

  attributes_table do
    row :profilepic do
      image_tag admin_user.profilepic.url, class: 'my_image_size'
    end
  row :name
  row :email
  row :adrs
  row :phone
  row :role
  row :salary
  row :parent_id
  row :joindate
end

结尾

于 2016-05-10T06:59:37.163 回答
0

Package这将显示一个具有has_many关系的对象示例( FAQS)

  show do |package|
    attributes_table do
      row :slug
      ...
      row :hotel
      panel "FAQS" do
        table_for package.faqs do
          column :question
          column :answer
        end
      end
    end
  end

它将呈现如下:

在此处输入图像描述

于 2019-06-13T02:05:36.270 回答