Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where to define my CSS #738

Closed
samdebutcha opened this issue Sep 23, 2011 · 27 comments
Closed

Where to define my CSS #738

samdebutcha opened this issue Sep 23, 2011 · 27 comments

Comments

@samdebutcha
Copy link
Contributor

In readme "Fields - Column CSS class"

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

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']
end
@samdebutcha
Copy link
Contributor Author

Please someone to throw some comment here please

@amalagaura
Copy link

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?

#765

@woahdae
Copy link
Contributor

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
Copy link
Contributor

woahdae commented Dec 16, 2011

From the SASS docs:

:load_paths
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
Copy link
Contributor

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?

@yesezra
Copy link
Contributor

yesezra 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
Copy link
Collaborator

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
Copy link
Contributor

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.

@rystraum
Copy link

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
Copy link
Contributor

jmondo commented Jul 28, 2012

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

@Tuckie
Copy link

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 :)

@pazaricha
Copy link

so any answer to this?

@caboteria
Copy link
Collaborator

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

@ideadapt
Copy link
Contributor

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}).

@aomahony
Copy link

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?

@johnkueh
Copy link

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

@ideadapt
Copy link
Contributor

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
    else
      # 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
    end
  end
end

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.

@chrisbloom7
Copy link

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.

@chrisbloom7
Copy link

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

@chrisbloom7
Copy link

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.

@johnkueh
Copy link

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!

@leebrooks0
Copy link

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

@leepowers
Copy link

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
Copy link

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

@KonstantinKo
Copy link

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
Copy link

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'

@commodoretyler
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests