Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 468
Tony Avatar asked Dec 16 '22 11:12

Tony


2 Answers

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
like image 77
RebeccaD Avatar answered Jan 10 '23 12:01

RebeccaD


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                                   
like image 37
Fivell Avatar answered Jan 10 '23 13:01

Fivell