ActiveAdmin display default view content

Jason Yost picture Jason Yost · Jul 22, 2012 · Viewed 7.5k times · Source

I am working with ActiveAdmin and need to make customizations to some views and have come across a couple of scenarios I feel I am doing wrong.

I am adding an additional table to a show view (comments on Posts). This requires me to rewrite the whole attributes table and then add my panel. Is there a way to customize views without losing the default content?

I would also like to add a table of associated items on the show view which doesn't need to be customized is there any way to include the default tale that would normally be on the index view with default actions and paging?

Answer

Cristian picture Cristian · Oct 29, 2012

After digging in the source code of Active Admin, I've found a way to patch this

  show do
    default_main_content
    panel "Your Added Stuff" do
      # Add stuff here
    end
  end

Of course this is undocumented and maybe considered a hack, but unless any other solution exists, it works.

Note: To do this in the form action (new and edit):

  form do |f|
    f.inputs
    # Other inputs here

    f.actions
  end