Customizing the show page in ActiveAdmin

五迷三道 提交于 2019-12-21 04:13:37

问题


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.

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?

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.

Thanks!


回答1:


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!)




回答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

end




回答3:


This will show an example of an object Package with a has_many relationship (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

It will be rendered like this:



来源:https://stackoverflow.com/questions/7510551/customizing-the-show-page-in-activeadmin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!