Tony
Tony

Reputation: 10208

Adding a top section in the index page of ActiveAdmin

I want to add some general information on active_admin top section.

For example, I want to render a partial at the top of the index page, so i can show something like

If I do it like I found in the documentation, It repeats for each element.

index do
  render :partial=>'foo', :layout=>false
  column :image_title
  default_actions
end

I want to render :partial=>'foo', :layout=>false just ONCE.

Any help?

Upvotes: 4

Views: 2220

Answers (2)

RebeccaD
RebeccaD

Reputation: 284

You can totally do this. You just might need to wrap it in an arbre component.

index do
  panel "Foo", :id => "foo-panel" do
    render :partial => "foo"
  end
  column :image_title
  default_actions
end

Upvotes: 10

Fivell
Fivell

Reputation: 11929

class ::ActiveAdmin::Views::IndexAsAdminUser < ActiveAdmin::Views::IndexAsTable

    def build(page_presenter, collection)
       para "My custom text"
       #or put _foo.html.erb to views/admin/admin_users
       # render :partial=>'help', :layout=>false 
       super
     end
end


ActiveAdmin.register AdminUser do
  config.batch_actions = false

  actions :index, :show


  index  as: :admin_user do  #<---- as: :admin_user to load class ::ActiveAdmin::Views::IndexAsAdminUser  
    column :username
    column :email
    column :current_sign_in_at        
    column :last_sign_in_at           
    column :sign_in_count             
    default_actions                   
  end                                 

  filter :username


end                                   

Upvotes: 5

Related Questions