在ActiveAdmin中自定义显示页面 [英] Customizing the show page in ActiveAdmin
问题描述
ActiveAdmin中的默认显示页面是一个表格,每行一个属性。对于我的后端,这很好,只不过我想隐藏id,created_at,updated_at等字段。
The default show page in ActiveAdmin is a table with one attribute per row. For my backend, this would be fine, except that I want to hide fields such as id, created_at, updated_at.
可以用类似于索引页面,即通过显式列出所需的属性,同时让AtiveAdmin处理布局?
Is is possible to do that in a way similar to the index page, i.e. by explicitly listing the desired attributes, while letting AtiveAdmin handle the layout?
文档中显示的唯一示例建议您自定义显示页面完全接管并编写部分或arbre构造。
The only example shown in the docs suggests that to customize the show page you have to completely take over and write a partial or an arbre construct.
谢谢!
推荐答案
我认为您正在寻找attribute_table:
I think you're looking for attributes_table:
show do
attributes_table :name, :content
end
请参见 https://github.com/gregbell/active_admin/blob/master/lib/active_admin/views/pages/show。 rb 如果您好奇的话。
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!)
这篇关于在ActiveAdmin中自定义显示页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!