How do I edit or override the footer of ActiveAdmin?

前端 未结 6 1230
南旧
南旧 2021-02-14 09:11

How do I edit or override the footer of Active_Admin?

6条回答
  •  执笔经年
    2021-02-14 10:01

    Answer:

    In your rails app, create this file: app/admin/footer.rb

    The content would be something like:

    module ActiveAdmin
      module Views
        class Footer < Component
    
          def build
            super :id => "footer"                                                    
            super :style => "text-align: right;"                                     
    
            div do                                                                   
              small "Cool footer #{Date.today.year}"                                       
            end
          end
    
        end
      end
    end
    

    Don't forget! restart the app/server.

    Any ActiveAdmin layout component can be customized like this.

    More about it:

    Why does it work? This is Ruby's magic sauce. We are reopening the definition of the Footer class and changing it for our custom content.

    Is it totally customizable? I don't know. This is the inheritance path:

    ActiveAdmin

    class Component < Arbre::Component
    class Footer < Component
    

    Arbre

    class Component < Arbre::HTML::Div
    

    This means that we can use Arbre's DSL directly.

提交回复
热议问题