Rails: fix ActiveAdmin CSS over-riding problem

November 3, 2011

For some reason the ActiveAdmin gem, a great administration framework for rails apps, has its own CSS files loaded for ALL other views (only trying in dev env). Quite annoying and will over-ride your styles. To fix I have just moved the app/assets/stylesheets/active_admin.css.scss to vendor/assets/stylesheets/active_admin.css.scss – It is only loaded when required then.

This example html…

<div id="header">
<div id="utility_nav">
<%= link_to "My Blog", posts_path %>
</div></div>

 

…looks like this with ActiveAdmin installed.

Because ActiveAdmin has this CSS.

/* line 110, /usr/lib/ruby/gems/1.8/gems/activeadmin-0.3.2/app/assets/stylesheets/active_admin/_header.css.scss */
#header #utility_nav {
  position: absolute;
  right: 25px;
  top: 10px;
  color: #aaa;
}

Moving the CSS file app/assets/stylesheets/active_admin.css.scss to vendor/assets/stylesheets/active_admin.css.scss restores the styling and allows active_admin.css to be loaded when required.

4 comments

  1. Wes - November 24, 2011 03:57

    Thanks for publicizing this fix. I just installed activeadmin, saw the problem, saw what activeadmin was doing to my site, and promptly uninstalled it. I don’t mind it defining styles for its own area, but I don’t know how anyone tolerates this takeover of the whole site’s css.

    Of course I saw your fix after I uninstalled activeadmin. Maybe I’ll give it another try, but if it starts costing me more time than it saves….

    Reply
  2. Franco - December 18, 2011 15:23

    Thanks! That worked fine for me!

    Reply
  3. Pingback: Website upgrade 2011 | robertomurray.co.uk

  4. Filipe Chagas - March 8, 2012 19:43

    Thank you guy!!! It helped me a lot!

    Reply

Have your say