Skip to content

Instantly share code, notes, and snippets.

@francois-ferrandis
Created March 7, 2018 11:59
Show Gist options
  • Save francois-ferrandis/1dc749262e7376e62074f908ee70356b to your computer and use it in GitHub Desktop.
Save francois-ferrandis/1dc749262e7376e62074f908ee70356b to your computer and use it in GitHub Desktop.
Customize the active admin layout
# config/initializers/active_admin.rb
# ...rest of the initializer here...
module AdminPageLayoutOverride
def build(*args)
# you can move the call to super at the end, if you wish
# to insert things at the begining of the page
super
# this will be added at the end of <body>
within @body do
render partial: '...'
end
# this will be added at the end of <head>
within @head do
text_node(javascript_include_tag('...))
end
end
end
ActiveAdmin::Views::Pages::Base.send :prepend, AdminPageLayoutOverride
@tobycox
Copy link

tobycox commented Jul 14, 2020

Note that the above didn't work for me on AA 2.7, but this comment did: activeadmin/activeadmin#5201 (comment)

@leenasn
Copy link

leenasn commented Jul 14, 2020

Note that the above didn't work for me on AA 2.7, but this comment did: activeadmin/activeadmin#5201 (comment)

That worked. Thanks @tobycox.

@mcfoton
Copy link

mcfoton commented Jul 7, 2022

Thanks. I was finally able to change AA color, even though we're using the same build to deploy to multiple environments

def build_active_admin_head
    within super do
      text_node("<style>:root {--primary-color: #{Rails.env.production? ? '#ff8b41' : '#505050'};}</style>".html_safe)
    end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment