How do I edit or override the footer of ActiveAdmin?

How do I edit or override the footer of Active_Admin?

Answers


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.


If all you want to do is change or delete the 'powered by' message, what you can do is change its value in a locale file. Example, edit config/locales/en.yml

And use something like this:

en:                                                                              
  active_admin:                                                                  
    powered_by: "Powered by hamsters"

Why this works:

The default locale for a rails app is english, the en locale file.


From gist create file in lib/footer.rb

class Footer < ActiveAdmin::Component
  def build
    super :id => "footer"
    span "My Awesome footer"
  end
end

add to initializers/active_admin.rb

ActiveAdmin.setup do |config|
 ......some config here....

  config.view_factory.footer = Footer

 ......some config here....
end

Between v1.0.4pre and v.1.0.5pre, the previous method of overriding Footer#build no longer works well, and the new API is

ActiveAdmin.application.footer = proc {
  ...
}

For v.1.0.0.pre5 I found that the Accepted Answer requires a small additiion, namely adding a variable to build as below:

module ActiveAdmin
  module Views
    class Footer < Component

      def build (namespace)
        super :id => "footer"                                                    
        super :style => "text-align: right;"                                     

        div do                                                                   
          small "Cool footer #{Date.today.year}"                                       
        end
      end

    end
  end
end

Need Your Help

Force Git submodules to always stay current

git git-submodules

I love git submodules. Also, I hate git submodules. What I love about them is how it enables to you to cleanly compartmentalize dependencies etc. I get the point of having them point to a specific

modal View controllers - how to display and dismiss

ios objective-c uiviewcontroller presentviewcontroller dismissviewcontroller

I'm breaking my head for the last one week on how to solve the issue with showing and dismissing multiple view controllers. I have created a sample project and pasting the code directly from the pr...