Where to define my CSS #738

samdebutcha opened this Issue Sep 23, 2011 · 27 comments


None yet

samdebutcha commented Sep 23, 2011

In readme "Fields - Column CSS class"

config.model Team do
    list do
      field :name
      field :created_at do
        css_class "customClass"

where I should define customClass, except the hook:

before_filter :if => Proc.new{ |c| c.request.path =~ /admin/ } do
    @head_stylesheet_paths = ['rails_admin_custom.css']

samdebutcha commented Nov 17, 2011

Please someone to throw some comment here please

I am also struggling with this, I see this description in a file:

Customize RailsAdmin theme here.
Copy this file to your app/assets/rails_admin/custom/theming.css.scss, leave this one untouched

I tried creating that file, but it still is not loaded, is it related to this?



woahdae commented Dec 16, 2011

That was a typo, should have been app/assets/stylesheets/rails_admin/custom/theming.css.scss

Still, doesn't work for me. It should though, not sure why it's not picking up the files in my app/assets/stylesheets/...


woahdae commented Dec 16, 2011

From the SASS docs:

An array of filesystem paths or importers which should be searched for Sass templates imported with the @import directive. These may be strings, Pathname objects, or subclasses of Sass::Importers::Base. This defaults to the working directory and, in Rack, Rails, or Merb, whatever :template_location is. [emphasis mine]

rails_admin/imports.css.scss uses relative paths that would never hit your app if the SASS docs are to be taken seriously.


woahdae commented Dec 16, 2011

Noticed that rails_admin/rails_admin.css is using sprockets to require rails_admin/imports.css.scss.erb. Therefore, if you also copy rails_admin/imports.css.scss, sprockets will pick up your imports.css.scss.erb first, which will then look in the current directory before the rails_admin directory.

This is definitely a work-around, not sure what the real solution is. Using sprockets in custom/*.css.scss?


ahhrrr commented Dec 23, 2011

I'm also having this problem. Copying the rails_admin/imports.css.scss.erb file is working for me, but does feel like a hack.


bbenezech commented Apr 7, 2012

Weird. It worked when I added the feature (it was picking app's file before the dummy RailsAdmin one).

Anyone with an idea for a fix?


ehoch commented Apr 19, 2012

Do we have a solution for this? It's definitely not working for me... But I should say that overring ui.js has been working beautifully for my javascript.

For those that found a workaround, what exactly did you do?
Copying app/assets/stylesheets/rails_admin/(imports/rails_admin) to my app does not seem to do anything.
Neither does trying to override app/assets/rails_admin/custom/ui.js as ehoch did. (Thought I might apply the CSS through JS instead.)


jmondo commented Jul 28, 2012

I'm also struggling with this. Let us know if you've found a workaround!

Tuckie commented Sep 21, 2012

tmp/cache delete to the rescue!

I was having the same issue, and then I gave the:

Don't forget to re-compile your assets or simply delete the content of your tmp/cache folder.

a shot and all is well :)

so any answer to this?


caboteria commented Aug 29, 2013

Based on @Tuckie's comment it looks as if this was a cache issue. If not, please re-open.

caboteria closed this Aug 29, 2013


ideadapt commented Oct 18, 2013

I had to copy over rails_admin/rails_admin.js and add it to precompile, then everything worked. Same procedure with rails_admin/rails_admin.scss.erb (add the compiled name to precompile += %w{rails_admin/rails_admin.css}).

This is not working at all. I've tried everything I can to get this to work, and it doesn't seem to want to use my rails_admin/custom/theming.css.scss (or theming.scss) file. I've deleted tmp/cache, recompiled my assets, edited the manifest file, everything. Can someone give me a simple example of how to override theming.scss?

It works for me on my local machine, but it still serves the old assets on Heroku. Anyone found a fix yet?


ideadapt commented Dec 15, 2013

I also had some problems with old assets being served. After I stumbled over rails/sprockets-rails#95 I realized that I have to create non digest assets for some ckeditor resources, because sprockets is not always able to update referencing digests as expected. I use the following rake task todo so:

# based on https://gist.github.com/markbao/6431880
require 'fileutils'

desc "Create nondigest versions of all ckeditor digest assets"
task "assets:precompile" => :environment do
  fingerprint = /\-([0-9a-f]{32})\./
  #for file in Dir["public/assets/ckeditor/**/*"]
  for file in Dir['public/assets/ckeditor/skins/moono/*.png', 'public/assets/ckeditor/config-*.js', 'public/assets/ckeditor/config-*.js.gz']
    # Skip file unless it has a fingerprint
    next unless file =~ fingerprint

    # Get filename of this file without the digest
    # (example) public/assets/ckeditor/config.js
    nondigest = file.sub fingerprint, '.'

    # Create a filename relative to public/assets
    # (example) public/assets/ckeditor/config.js => ckeditor/config.js
    filename = nondigest.sub 'public/assets/', ''
    filename = filename.sub /.gz$/, '' # Remove .gz for correct asset checking

    # Fetch the latest digest for this file from assets
    latest_digest = Rails.application.assets.find_asset(filename).digest

    # Compare digest of this file to latest digest
    # [1] is the enclosed capture in the fingerprint regex above
    this_digest = file.match(fingerprint)[1]
    if (this_digest == latest_digest)
      # This file's digest matches latest digest, copy
      #puts 'Matching digest, copying ' + file
      FileUtils.cp file, nondigest, verbose: true
      # This file's digest doesn't match latest digest, ignore
      puts 'Non-matching digests, use latest digest to create ' + nondigest
      puts 'Latest digest: ' + latest_digest
      puts 'This digest:   ' + this_digest
      #puts 'Non-matching digest, not copying ' + file
      FileUtils.cp "public/assets/#{Rails.application.assets.find_asset(filename).digest_path}", nondigest, verbose: true

This rake task is executed after each assets:precompile, hence the new files will be in the heroku slug, and are not deleted after e.g. a dyno restart.

Having the same problem as @aomahony. This is on a development machine, so there shouldn't be any asset precompiling anyway. I did delete my tmp/cache folder just to be safe, but still no difference. This is on Rails 4.0 with RA 0.6.0.

Restarting the server seemed to do the trick on development. Fingers crossed that it works on production/staging.

Nope, does not work in my staging environment on Heroku :(

If I precompile it locally, I can see the custom CSS is added to the rails_admin.css file, but this doesn't seem to work on Heroku using it's deploy-time asset precompiling. I'd rather not have to rely on precompiling locally before each deploy.

Anyone found a fix? I've tried everything but it still doesnt work on staging/production on Heroku. Works on local dev environment. Please help, thanks!

+1 @chrisbloom7 restarting the server did the trick for me too.

Nothing in this thread worked for me.

Problem was, I was following the following instructions, as found in app/assets/styleheets/rails_admin/custom/theming.scss:

Copy this file to your app/assets/styleheets/rails_admin/custom/theming.css.scss, leave this one untouched

What worked: ignoring these instructions, overwriting theming.scss instead of copying to theming.css.scss and recompiling assets with bundle exec rake assets:precompile

dmilisic commented Aug 7, 2014

Here is what worked for me:

I copied default theme from rails admin gem app/assets/stylesheets/rails_admin/themes/default to my application app/assets/stylesheets/rails_admin/themes/xyz and edited theming.scss file.

In config/application.rb i added ENV['RAILS_ADMIN_THEME'] = 'xyz' after Bundler.require(*Rails.groups).

That worked for development but i couldn't force heroku to recompile rails_admin.css.

Changing asset version in config/initializers/assets.rb to Rails.application.config.assets.version = '1.1' did the trick - heroku recompiled all assets. This configuration can be found in config/environments/production.rb for older Rails versions.

Hope it helps someone

So, I had the same problem and discovered that yes, for me it was a caching problem as well. I just didn't restart the server and cleared the tmp/cache and precompiled assets at the same time.

In the process of discovering this I created a minimal testing app: https://github.com/KonstantinKo/rails_admin_issue_738_test

Since people still seem to have this issue:
To help debugging I propose you fork that project and get it to fail with what you were doing.

u007 commented Jan 1, 2015

ive followed dmilisic configuration,
and setting this seems to does the trick even in development environment

Rails.application.config.assets.version = '1.1'

Clearing tmp/cache and restarting the server worked for me as well. This really should be in the docs.

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